indexing description: "[ Test for Eiffel-GigaSpaces wrapper loosely based on POCO benchmark example ]" status: "See notice at end of class." legal: "See notice at end of class." date: "$Date$" revision: "$Revision$" deferred class BENCHMARK_TEST inherit EGS_SHARED_EXCEPTION_HANDLER undefine print end EXCEPTION_MANAGER_FACTORY undefine print end BENCHMARK_PRINT_HELPER feature duration: DOUBLE failed: BOOLEAN benchmark: BENCHMARK transaction: EGS_TRANSACTION thread_index: INTEGER name: STRING is -- deferred end space_proxy: EGS_SPACE_PROXY space_proxy_cache: EGS_SPACE_PROXY set_failed (is_failed: like failed) is -- do failed := is_failed end set_proxy (proxy: like space_proxy) is do space_proxy := proxy end set_proxy_cache (proxy: like space_proxy_cache) is do space_proxy_cache := proxy end set_benchmark (a_benchmark: BENCHMARK) is -- do benchmark := a_benchmark end set_thread_index (a_thread_index: INTEGER) is -- do thread_index := a_thread_index end set_up is local batch_count: INTEGER tmp_lease: ANY i, j: INTEGER batch: ARRAY[BENCHMARK_BASE_OBJECT] object: BENCHMARK_BASE_OBJECT do if not failed then batch_count := benchmark.iterations // benchmark.batch_size create batch.make (1, benchmark.batch_size) from i := batch.lower until failed or i > batch.upper loop batch.put (create_new_object_for_benchmark, i) i := i+1 end from i := 1 until i > batch_count loop from j := batch.lower until failed or j > batch.upper loop object := batch.item (j) object.set_uid ("") set_id (object, (i - 1) * benchmark.batch_size + j - 1) j := j + 1 end tmp_lease := space_proxy.write_multiple (batch, transaction, {EGS_LEASE}.forever); failed := test_exception i := i + 1 end end rescue -- Note that this code is only for raise_xap_exception exceptions_handling_discipline handle_raised_exception (exception_manager.last_exception) failed := True retry end tear_down is do end run is local i: INTEGER do from i := 1 until failed or i > benchmark.iterations loop run_iteration (i) i := i+1 end end feature {NONE} -- Implementation run_iteration (index: INTEGER) is -- deferred end start_timing is -- do create start_time.make_now end end_timing is -- local current_time: TIME do create current_time.make_now duration := duration + current_time.relative_duration (start_time).fine_seconds_count end create_transaction is -- do if benchmark.transaction_mode = benchmark.local_transaction then transaction := space_proxy.create_local_transaction (60000) elseif benchmark.transaction_mode = benchmark.jini_transaction then -- TODO transaction := Void end end commit_transaction is -- do if transaction /= Void then -- TODO -- transaction.commit end end create_new_object_template: BENCHMARK_BASE_OBJECT is -- do Result := benchmark.create_new_object_template ensure result_not_void: Result /= Void end create_new_object_for_benchmark: BENCHMARK_BASE_OBJECT is -- do Result := benchmark.create_new_object_for_benchmark ensure result_not_void: Result /= Void end create_benchmark_object_from_entry (an_entry: EGS_ENTRY): BENCHMARK_BASE_OBJECT is -- do Result := benchmark.create_benchmark_object_from_entry (an_entry) end set_id (an_object: BENCHMARK_BASE_OBJECT; index: INTEGER) is -- require an_object_not_void: an_object /= Void do an_object.set_id (get_id (index)) end set_uid (an_object: BENCHMARK_BASE_OBJECT; uid: STRING) is -- require an_object_not_void: an_object /= Void uid_not_void: uid /= Void do an_object.set_uid ("") end update_object (an_object: BENCHMARK_BASE_OBJECT; index: INTEGER) is -- Updates the object data for update test require an_object_not_void: an_object /= Void do benchmark.update_object (an_object, index) end get_id (index: INTEGER): INTEGER is -- do Result := index + thread_index * (benchmark.iterations+1) end handle_exception is -- Test and clear the possible exception occured do if was_exception then print ("%TException occured, ExceptionName = ") print (last_exception.name) print ("%N") clear_exception end end test_exception: BOOLEAN is -- Test and clear the possible exception occured do if was_exception then Result := True print ("%TException occured, ExceptionName = " + last_exception.name + "%N") clear_exception end end handle_raised_exception (an_exception: EXCEPTION) is -- Handle the raised XAP exception local xap_exception: EGS_XAP_EXCEPTION do xap_exception ?= an_exception if xap_exception /= Void then print ("%TException occured, ExceptionName = " + xap_exception.name + "%N") clear_exception end end start_time: TIME feature indexing copyright: "Copyright (c) 2008, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 356 Storke Road, Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end