Browse files

First try at isolating several CiAN applications using different clas…

…s loaders.

git-svn-id: http://north.dsg.cs.tcd.ie/repos/simulator-workflow@14 6aedb14f-efc7-4c1d-8d98-6d0cd5b8577c
  • Loading branch information...
1 parent 7a448e0 commit 9a6b608d2cd654ff5f8ca7b84b4b025b4c968148 @jalliot committed Aug 9, 2011
Showing with 9,264 additions and 9,655 deletions.
  1. +273 −1 .settings/org.eclipse.jdt.core.prefs
  2. +3 −1 .settings/org.eclipse.jdt.ui.prefs
  3. +197 −202 ducks/src/ducks/controller/ControllerProxy.java
  4. +343 −361 ducks/src/ducks/controller/DucksController.java
  5. +19 −19 ducks/src/ducks/controller/DucksControllerModule.java
  6. +112 −122 ducks/src/ducks/controller/output/LogFile.java
  7. +374 −407 ducks/src/ducks/controller/output/MySQLDatabase.java
  8. +193 −211 ducks/src/ducks/controller/output/StorageManager.java
  9. +11 −12 ducks/src/ducks/controller/output/StorageProvider.java
  10. +313 −320 ducks/src/ducks/controller/server/Server.java
  11. +222 −224 ducks/src/ducks/controller/server/ServerManager.java
  12. +474 −495 ducks/src/ducks/controller/simulation/DefaultSimulationMultiplexer.java
  13. +248 −248 ducks/src/ducks/controller/simulation/Simulation.java
  14. +180 −186 ducks/src/ducks/controller/simulation/SimulationInstance.java
  15. +12 −14 ducks/src/ducks/controller/simulation/SimulationMultiplexer.java
  16. +192 −197 ducks/src/ducks/controller/simulation/SimulationStudy.java
  17. +190 −198 ducks/src/ducks/controller/simulation/VariableSimulationMultiplexer.java
  18. +41 −45 ducks/src/ducks/driver/CianBaseNode.java
  19. +9 −10 ducks/src/ducks/driver/CianHost2Node.java
  20. +9 −10 ducks/src/ducks/driver/CianHost3Node.java
  21. +10 −10 ducks/src/ducks/driver/CianPlannerNode.java
  22. +29 −33 ducks/src/ducks/driver/ConsumerNode.java
  23. +5 −5 ducks/src/ducks/driver/DucksDriverModule.java
  24. +95 −100 ducks/src/ducks/driver/GenericDriver.java
  25. +529 −562 ducks/src/ducks/driver/GenericNode.java
  26. +227 −255 ducks/src/ducks/driver/GenericNodes.java
  27. +364 −437 ducks/src/ducks/driver/GenericScene.java
  28. +256 −278 ducks/src/ducks/driver/Main.java
  29. +9 −10 ducks/src/ducks/driver/Node.java
  30. +6 −6 ducks/src/ducks/driver/Nodes.java
  31. +23 −25 ducks/src/ducks/driver/ProviderNode.java
  32. +6 −6 ducks/src/ducks/driver/Scene.java
  33. +214 −214 ducks/src/ducks/driver/SimParams.java
  34. +38 −43 ducks/src/ducks/driver/WorkflowInitiatorNode.java
  35. +58 −65 ducks/src/ducks/driver/WorkflowProviderNode.java
  36. +186 −199 ducks/src/ducks/eventlog/EventLog.java
  37. +7 −7 ducks/src/ducks/eventlog/EventLogModule.java
  38. +34 −37 ducks/src/ducks/eventlog/destinations/CSV.java
  39. +53 −60 ducks/src/ducks/eventlog/destinations/GnuPlot.java
  40. +19 −21 ducks/src/ducks/eventlog/destinations/Log4J.java
  41. +188 −215 ducks/src/ducks/eventlog/destinations/SVG.java
  42. +17 −17 ducks/src/ducks/eventlog/modules/Movement.java
  43. +12 −12 ducks/src/ducks/misc/DucksException.java
  44. +537 −576 jist-swans-1.0.6/src/driver/CBR.java
  45. +504 −555 jist-swans-1.0.6/src/driver/aodvsim.java
  46. +193 −204 jist-swans-1.0.6/src/driver/aodvtest.java
  47. +638 −702 jist-swans-1.0.6/src/driver/bordercast.java
  48. +212 −226 jist-swans-1.0.6/src/driver/dsrtest.java
  49. +159 −176 jist-swans-1.0.6/src/driver/heartbeat.java
  50. +166 −187 jist-swans-1.0.6/src/driver/ip.java
  51. +112 −117 jist-swans-1.0.6/src/driver/memory.java
  52. +356 −394 jist-swans-1.0.6/src/driver/ndp.java
  53. +235 −258 jist-swans-1.0.6/src/driver/spatial.java
  54. +195 −196 jist-swans-1.0.6/src/driver/tcp.java
  55. +41 −43 jist-swans-1.0.6/src/driver/threaded.java
  56. +116 −121 jist-swans-1.0.6/src/driver/udp.java
Sorry, we could not display the entire diff because it was too big.
View
274 .settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Mon Aug 08 10:03:50 IST 2011
+#Tue Aug 09 16:58:45 IST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
@@ -79,3 +79,275 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=true
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=true
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=false
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=120
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
View
4 .settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,4 @@
-#Tue Aug 09 09:59:46 IST 2011
+#Tue Aug 09 16:58:45 IST 2011
cleanup.add_default_serial_version_id=true
cleanup.add_generated_serial_version_id=false
cleanup.add_missing_annotations=true
@@ -53,4 +53,6 @@ cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup_profile=_Custom1
cleanup_settings_version=2
eclipse.preferences.version=1
+formatter_profile=_Custom1
+formatter_settings_version=12
internal.default.compliance=default
View
399 ducks/src/ducks/controller/ControllerProxy.java
@@ -1,7 +1,7 @@
/*
* Ulm University DUCKS project
*
- * Author: Elmar Schoch <elmar.schoch@uni-ulm.de>
+ * Author: Elmar Schoch <elmar.schoch@uni-ulm.de>
*
* (C) Copyright 2006, Ulm University, all rights reserved.
*
@@ -12,9 +12,8 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
*/
package ducks.controller;
@@ -46,204 +45,200 @@
* @author Elmar Schoch
*
*/
-public class ControllerProxy implements Runnable {
-
- public static int GET_INVALID = -1;
- public static int GET_SIMUSTATE = 1;
- public static int GET_SERVERSTATE = 2;
-
- /**
- * The port the controller is listening on
- */
- public static int PORT = 3330;
-
- // log4j Logger
- private static Logger log = Logger.getLogger(ControllerProxy.class
- .getName());
-
- private boolean enabled = false;
- private ServerSocket srvsock = null;
-
- private DucksController dc;
-
- public ControllerProxy(DucksController dc) {
- this.dc = dc;
- }
-
- /**
- * Run the TCP server to accept requests
- */
- public void run() {
-
- try {
- srvsock = new ServerSocket(PORT);
- } catch (Exception e) {
- e.printStackTrace();
- log.debug("Controller proxy server socket could not be opened. "
- + e.getMessage());
- return;
- }
-
- Socket s = null;
-
- while (enabled) {
- try {
-
- s = srvsock.accept();
- s.setSoTimeout(15000);
- BufferedReader in = new BufferedReader(new InputStreamReader(
- s.getInputStream()));
-
- String l;
- String reqSt = "";
- while (true) {
- l = in.readLine();
- if (l.equals("")) {
- break;
- } else {
- reqSt += l;
- }
- }
-
- Request r = parseRequest(reqSt);
-
- PrintStream os = new PrintStream(s.getOutputStream());
- os.print(r.getResponse());
- os.print("\n");
-
- s.close();
-
- } catch (Exception e) {
- if (s != null) {
- if (!s.isClosed()) {
- try {
- s.close();
- } catch (Exception ex) {
- }
- }
- }
- }
- }
- }
-
- /**
- * Enable or disable external controlling ability
- *
- * @param enabled
- */
- synchronized public void setEnabled(boolean enabled) {
-
- if (enabled && !this.enabled) {
- Thread t = new Thread(this);
- t.start();
- }
-
- this.enabled = enabled;
- }
-
- /**
- * Main method invoked on receiving a request
- *
- * @param req
- * complete request as string
- * @return Parsed request object (
- * @throws DucksException
- */
- private Request parseRequest(String req) throws DucksException {
-
- Request r = null;
-
- String[] lines = req.split("\n");
-
- log.debug("Got request: " + req + " (" + lines.length + " lines)");
-
- if (lines.length >= 1) {
- String[] parts = lines[0].split(" ");
- if (parts.length >= 2) {
- if (parts[0].trim().equals("GET")) {
- GetRequest gr = new GetRequest();
- gr.requestedItem = GET_INVALID;
-
- if (parts[1].trim().equals("simustate")) {
- gr.requestedItem = GET_SIMUSTATE;
- }
- if (parts[1].trim().equals("serverstate")) {
- gr.requestedItem = GET_SERVERSTATE;
- }
-
- r = gr;
- }
- }
- }
-
- return r;
- }
-
- public interface Request {
- public String getResponse();
- }
-
- public class GetRequest implements Request {
-
- public int requestedItem = GET_INVALID;
-
- public String getResponse() {
-
- String result = "404 Not found\n\n";
-
- if (requestedItem == GET_INVALID) {
- result = "400 Bad request\n\n";
- }
-
- if (requestedItem == GET_SIMUSTATE) {
- result = "200 OK\n\n";
- Enumeration studies = dc.getSimulationStudies().elements();
- while (studies.hasMoreElements()) {
-
- SimulationStudy study = (SimulationStudy) studies
- .nextElement();
- Enumeration simus = study.getSimulations().elements();
- while (simus.hasMoreElements()) {
- Simulation s = (Simulation) simus.nextElement();
- // format: run-id, simu-id, simu-state, remaining inst,
- // running inst, done inst, failed inst
- int[] sstate = s.getStateInfo();
- result += "0," + s.getIdentifier() + "," + s.getState()
- + "," + sstate[0] + ","
- + sstate[SimulationInstance.RUNNING] + ","
- + sstate[SimulationInstance.DONE] + ","
- + sstate[SimulationInstance.FAILED] + "\n";
- }
- }
- }
-
- if (requestedItem == GET_SERVERSTATE) {
- result = "200 OK\n\n";
-
- Iterator servers = dc.getServers().getAll().iterator();
- while (servers.hasNext()) {
- Server srv = (Server) servers.next();
- SimulationInstance si = srv.getCurrentSimInstance();
- long runID = -1;
- int simuID = -1;
- if (si != null) {
- Simulation s = si.getSimulation();
- simuID = s.getIdentifier();
- runID = s.getSimStudy().getIdentifier();
- }
-
- // format: srv-identifier, host, port, state, current
- // SimRun, current Simu
- result += srv.getIdentifier() + "," + srv.getHost() + ","
- + srv.getPort() + "," + srv.getState() + ","
- + runID + "," + simuID + "\n";
- }
- }
-
- log.debug("Response on request: " + result);
-
- return result;
- }
- }
+public class ControllerProxy implements Runnable
+{
+
+ public static int GET_INVALID = -1;
+ public static int GET_SIMUSTATE = 1;
+ public static int GET_SERVERSTATE = 2;
+
+ /**
+ * The port the controller is listening on
+ */
+ public static int PORT = 3330;
+
+ // log4j Logger
+ private static Logger log = Logger.getLogger(ControllerProxy.class.getName());
+
+ private boolean enabled = false;
+ private ServerSocket srvsock = null;
+
+ private DucksController dc;
+
+ public ControllerProxy(DucksController dc) {
+ this.dc = dc;
+ }
+
+ /**
+ * Run the TCP server to accept requests
+ */
+ public void run() {
+
+ try {
+ srvsock = new ServerSocket(PORT);
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.debug("Controller proxy server socket could not be opened. " + e.getMessage());
+ return;
+ }
+
+ Socket s = null;
+
+ while (enabled) {
+ try {
+
+ s = srvsock.accept();
+ s.setSoTimeout(15000);
+ BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
+
+ String l;
+ String reqSt = "";
+ while (true) {
+ l = in.readLine();
+ if (l.equals("")) {
+ break;
+ } else {
+ reqSt += l;
+ }
+ }
+
+ Request r = parseRequest(reqSt);
+
+ PrintStream os = new PrintStream(s.getOutputStream());
+ os.print(r.getResponse());
+ os.print("\n");
+
+ s.close();
+
+ } catch (Exception e) {
+ if (s != null) {
+ if (!s.isClosed()) {
+ try {
+ s.close();
+ } catch (Exception ex) {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Enable or disable external controlling ability
+ *
+ * @param enabled
+ */
+ synchronized public void setEnabled(boolean enabled) {
+
+ if (enabled && !this.enabled) {
+ Thread t = new Thread(this);
+ t.start();
+ }
+
+ this.enabled = enabled;
+ }
+
+ /**
+ * Main method invoked on receiving a request
+ *
+ * @param req
+ * complete request as string
+ * @return Parsed request object (
+ * @throws DucksException
+ */
+ private Request parseRequest(String req) throws DucksException {
+
+ Request r = null;
+
+ String[] lines = req.split("\n");
+
+ log.debug("Got request: " + req + " (" + lines.length + " lines)");
+
+ if (lines.length >= 1) {
+ String[] parts = lines[0].split(" ");
+ if (parts.length >= 2) {
+ if (parts[0].trim().equals("GET")) {
+ GetRequest gr = new GetRequest();
+ gr.requestedItem = GET_INVALID;
+
+ if (parts[1].trim().equals("simustate")) {
+ gr.requestedItem = GET_SIMUSTATE;
+ }
+ if (parts[1].trim().equals("serverstate")) {
+ gr.requestedItem = GET_SERVERSTATE;
+ }
+
+ r = gr;
+ }
+ }
+ }
+
+ return r;
+ }
+
+ public interface Request
+ {
+ public String getResponse();
+ }
+
+ public class GetRequest implements Request
+ {
+
+ public int requestedItem = GET_INVALID;
+
+ public String getResponse() {
+
+ String result = "404 Not found\n\n";
+
+ if (requestedItem == GET_INVALID) {
+ result = "400 Bad request\n\n";
+ }
+
+ if (requestedItem == GET_SIMUSTATE) {
+ result = "200 OK\n\n";
+ Enumeration studies = dc.getSimulationStudies().elements();
+ while (studies.hasMoreElements()) {
+
+ SimulationStudy study = (SimulationStudy) studies.nextElement();
+ Enumeration simus = study.getSimulations().elements();
+ while (simus.hasMoreElements()) {
+ Simulation s = (Simulation) simus.nextElement();
+ // format: run-id, simu-id, simu-state, remaining inst,
+ // running inst, done inst, failed inst
+ int[] sstate = s.getStateInfo();
+ result += "0," + s.getIdentifier() + "," + s.getState() + "," + sstate[0] + ","
+ + sstate[SimulationInstance.RUNNING] + "," + sstate[SimulationInstance.DONE] + ","
+ + sstate[SimulationInstance.FAILED] + "\n";
+ }
+ }
+ }
+
+ if (requestedItem == GET_SERVERSTATE) {
+ result = "200 OK\n\n";
+
+ Iterator servers = dc.getServers().getAll().iterator();
+ while (servers.hasNext()) {
+ Server srv = (Server) servers.next();
+ SimulationInstance si = srv.getCurrentSimInstance();
+ long runID = -1;
+ int simuID = -1;
+ if (si != null) {
+ Simulation s = si.getSimulation();
+ simuID = s.getIdentifier();
+ runID = s.getSimStudy().getIdentifier();
+ }
+
+ // format: srv-identifier, host, port, state, current
+ // SimRun, current Simu
+ result += srv.getIdentifier() + "," + srv.getHost() + "," + srv.getPort() + "," + srv.getState()
+ + "," + runID + "," + simuID + "\n";
+ }
+ }
+
+ log.debug("Response on request: " + result);
+
+ return result;
+ }
+ }
}
View
704 ducks/src/ducks/controller/DucksController.java
@@ -1,7 +1,7 @@
/*
* Ulm University DUCKS project
*
- * Author: Elmar Schoch <elmar.schoch@uni-ulm.de>
+ * Author: Elmar Schoch <elmar.schoch@uni-ulm.de>
*
* (C) Copyright 2007, Ulm University, all rights reserved.
*
@@ -12,9 +12,8 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
*/
package ducks.controller;
@@ -47,363 +46,346 @@
*
* @author Elmar Schoch
*/
-public class DucksController {
-
- // log4j Logger
- private static Logger log = Logger.getLogger(DucksController.class
- .getName());
-
- // (optional) remote management interface to the controller
- private ControllerProxy proxy;
- public static final String CGF_PROXY_ENABLED = "ducks.config.monitor.enabled";
-
- // list of available servers
- private ServerManager servers;
- // current result manager
- private StorageManager storage;
-
- // simulation studies
- private Vector<SimulationStudy> studies;
- // currently simulation study beeing processed
- private SimulationStudy currentStudy = null;
-
- public DucksController() {
- servers = new ServerManager(this);
- storage = new StorageManager();
-
- studies = new Vector<SimulationStudy>();
- }
-
- /**
- * Retrieve the server manager object
- *
- * @return server manager
- */
- public ServerManager getServers() {
- return servers;
- }
-
- /**
- * Retrieve the simulation study list
- *
- * @return simulation studies
- */
- public Vector getSimulationStudies() {
- return studies;
- }
-
- /**
- * Get first unscheduled simulation
- *
- * @return Simulation first unscheduled simulation
- * @see ducks.SimGeneratorInt
- */
- public synchronized SimulationInstance getFreeSimulation() {
- if (currentStudy != null) {
- return currentStudy.getPendingSimInstance();
- } else {
- return null;
- }
- }
-
- /**
- * Find a simulation study that has not been processed yet
- *
- * @return Unprocessed simulation study object, or null if none is available
- */
- private SimulationStudy getNextSimulationStudy() {
- for (int i = 0; i < studies.size(); i++) {
- SimulationStudy sst = (SimulationStudy) studies.get(i);
- if (!sst.hasFinished() && sst != currentStudy) {
- return sst;
- }
- }
- // no unprocessed study found
- return null;
- }
-
- /**
- * Main method
- *
- * @param args
- * Command line arguments for main. <li>-s / --simuconfig
- * filename : specify a simulation study config file to use <li>
- * -d / --ducksconfig filename : specify a ducks controller
- * config file to use (default ducks/resources/ducks.properties)
- * <li>-n / --nodb : run simulations without saving results to
- * database <li>-l / --debuglevel : set basic debug level (log4j:
- * INFO,WARN,DEBUG) <li>-p / --persist : do not exit controller,
- * if all studies are processed (i.e. wait for new ones via
- * remote proxy)
- *
- */
- public static void main(String[] args) {
-
- // Handling command line options & config properties
- // ............................
-
- CmdLineParser parser = new CmdLineParser();
- CmdLineParser.Option optSimuConfig = parser.addStringOption('s',
- "simuconfig");
- CmdLineParser.Option optDebugConfig = parser.addStringOption('d',
- "debugconfig");
- CmdLineParser.Option optDebugLevel = parser.addStringOption('l',
- "debuglevel");
- CmdLineParser.Option optPersist = parser.addIntegerOption('p',
- "persist");
- CmdLineParser.Option optNoSave = parser.addBooleanOption('n', "nosave");
-
- try {
- parser.parse(args);
- } catch (Exception e) {
- System.out.println("Error parsing commandline options: " + args);
- System.out.println("Usage: ");
- System.out.println(" -s --simuconfig <simulation config file>");
- System.out.println(" -p --persist (optional)");
- System.out.println(" -n --nosave (optional)");
- System.out
- .println(" -d --debugconfig <log4j config file> (optional)");
- System.out
- .println(" -l --debuglevel <root log4j level> (optional)");
- System.exit(99);
- }
-
- // Init log4j logging .................................................
- // 1. Control root level (can be set as well)
- // 2. Use detailed log4j properties, if given
- BasicConfigurator.configure();
-
- Level l = Level.ERROR;
- if (parser.getOptionValue(optDebugLevel) != null) {
- String loglevel = parser.getOptionValue(optDebugLevel).toString();
- l = Level.toLevel(loglevel, l);
- }
- Logger.getRootLogger().setLevel(l);
-
- if (parser.getOptionValue(optDebugConfig) != null) {
- File f = new File(parser.getOptionValue(optDebugConfig).toString());
-
- if (f.exists()) {
- System.out.println("Starting logging with file "
- + f.getAbsoluteFile());
- PropertyConfigurator.configure((parser
- .getOptionValue(optDebugConfig)).toString());
- }
- }
-
- System.out.println("RootLogger is on level "
- + Logger.getRootLogger().getLevel());
-
- // Loading configuration of simulation
- // ...........................................
- ExtendedProperties config = new ExtendedProperties();
- String configFilename = (String) parser.getOptionValue(optSimuConfig);
- if (configFilename == null) {
- // if nothing given at the command line, try "config.properties"
- configFilename = "config.properties";
- }
-
- try {
- config.loadFromFile(configFilename);
- } catch (IOException e) {
- log.error("Loading DUCKS config file failed: given filename: "
- + configFilename + " working dir: "
- + System.getProperty("user.dir") + " Exception: "
- + e.getMessage());
- e.printStackTrace();
- System.exit(1);
- }
-
- // Setup servers and storage
- // .........................................................
-
- DucksController dc = new DucksController();
-
- try {
- dc.servers.configure(config);
- } catch (Exception e) {
- log.error("Loading compute servers failed: " + e.getMessage());
- e.printStackTrace();
- System.exit(2);
- }
-
- // if no remote server is enabled, create a local server instead
- if (dc.servers.count() == 0) {
- log.warn("Could not find any enabled servers. Creating local server");
- if (!dc.servers.createLocalServer(5550)) {
- log.error("Could not create local server! Exiting ...");
- System.exit(2);
- }
- }
-
- boolean nosave = parser.getOptionValue(optNoSave) != null;
- if (nosave) {
- log.warn("Saving of results is disabled!");
- } else {
-
- try {
- dc.storage.configure(config);
- dc.storage.enable();
- log.info("Result storage providers are initialized");
-
- } catch (Exception e) {
- log.error("Opening result storage failed: " + e.getMessage());
- e.printStackTrace();
- System.exit(3);
- }
- }
-
- // Load simulation study ...............................................
-
- try {
- SimulationStudy simStudy = new SimulationStudy();
- simStudy.configure(config);
- dc.studies.add(simStudy);
-
- } catch (Exception e) {
- e.printStackTrace();
- log.error("Loading simulation study config failed: "
- + e.getMessage());
- }
-
- // Run simulations
- // ............................................................
-
- // set simulation study
- if (dc.studies.size() > 0) {
- dc.currentStudy = (SimulationStudy) dc.studies.get(0);
-
- if ((!nosave) && dc.storage.backgroundSavingEnabled()) {
- dc.storage.startBackgroundSaving(dc.currentStudy);
- }
- }
-
- // enable the simulation server threads
- dc.servers.enable();
-
- // enable remote monitoring and control of the DucksController
- // (currently only partly implemented)
- if (config.getBooleanProperty(DucksController.CGF_PROXY_ENABLED, false)) {
- dc.proxy = new ControllerProxy(dc);
- }
-
- // main loop
- while (true) {
-
- // Sleep for 10 seconds
- try {
- Thread.sleep(10000);
- } catch (Exception e) {
- }
-
- if (dc.currentStudy != null) {
- // we are currently processing a study
- if (dc.currentStudy.hasFinished()) {
- // current study has finished
-
- if ((!nosave) && dc.storage.backgroundSavingEnabled()) {
- dc.storage.stopBackgroundSaving();
- }
-
- // Save data to db (if no already done in while running)
- if ((!nosave) && (!dc.storage.backgroundSavingEnabled())) {
- try {
- dc.storage.saveAll(dc.currentStudy);
- } catch (Exception e) {
- log.error("Failure with simulation study "
- + dc.currentStudy.getIdentifier());
- log.error(" Saving results to database failed: "
- + e.getMessage());
- log.error(" Waiting for user intervention ...");
- e.printStackTrace();
- // wait for user intervention ... (e.g. reparing the
- // database)
- continue;
- }
- }
-
- // set currentStudy to null
- // -> will select next available in next iteration of the
- // main loop
- // or quit, or idle
- dc.currentStudy = null;
- } else {
- // current study still processing
- // -> give some stats
- int[] states = dc.currentStudy.getStateCount();
- String st = "State of study "
- + dc.currentStudy.getIdentifier() + ": ";
- st += "Pending: " + states[Simulation.PENDING] + ", ";
- st += "Running: " + states[Simulation.RUNNING] + ", ";
- st += "Finished: " + states[Simulation.FINISHED] + ", ";
- st += "Flushed: " + states[Simulation.FLUSHED];
- log.info(st);
- }
-
- } else {
- // do we have unfinished studies in the queue?
- SimulationStudy study = dc.getNextSimulationStudy();
- if (study != null) {
- // yeah, we have got one! -> set to current study and
- // continue!
- dc.currentStudy = study;
- } else {
- // not study any more? So, idle or exit
- if (parser.getOptionValue(optPersist) == null) {
- // ok, we do not want to persist, so exit loop here
- break;
- } else {
- // well, we shall persist, so wait ...
- log.info("Waiting for new simulation studies ...");
- }
- }
- }
-
- // Check if there are still processing servers available
- if (dc.currentStudy != null
- && dc.servers.numberOfEnabledServers() == 0) {
- log.warn("Number of enabled servers is zero, though simulations are pending!");
-
- if (dc.proxy != null) {
- // if we have a remote proxy, trust on user to re-activate
- // servers again
- log.warn("Waiting for manual server re-activation via remote controller");
- } else {
- // if not remote proxy exists, try to re-enable servers
- int currentMin = 5;
- while (currentMin > 0) {
- log.debug("Trying to re-enable all servers in "
- + currentMin + " minutes");
- currentMin--;
- try {
- Thread.sleep(60000);
- } catch (Exception e) {
- }
- }
- log.info("Re-enabling servers now ...");
- dc.servers.enable();
- }
- }
-
- }
-
- // Clean up
- // ...................................................................
- dc.servers.disable();
- dc.servers.stopLocalServer();
-
- try {
- if (dc.storage.backgroundSavingEnabled()) {
- dc.storage.stopBackgroundSaving();
- }
- dc.storage.saveReadyResults();
- dc.storage.disable();
- } catch (DucksException e) {
- log.warn("Storage provider disable problem: " + e.getMessage());
- }
-
- log.info("Terminating controller ...");
- System.exit(0);
- }
+public class DucksController
+{
+
+ // log4j Logger
+ private static Logger log = Logger.getLogger(DucksController.class.getName());
+
+ // (optional) remote management interface to the controller
+ private ControllerProxy proxy;
+ public static final String CGF_PROXY_ENABLED = "ducks.config.monitor.enabled";
+
+ // list of available servers
+ private ServerManager servers;
+ // current result manager
+ private StorageManager storage;
+
+ // simulation studies
+ private Vector<SimulationStudy> studies;
+ // currently simulation study beeing processed
+ private SimulationStudy currentStudy = null;
+
+ public DucksController() {
+ servers = new ServerManager(this);
+ storage = new StorageManager();
+
+ studies = new Vector<SimulationStudy>();
+ }
+
+ /**
+ * Retrieve the server manager object
+ *
+ * @return server manager
+ */
+ public ServerManager getServers() {
+ return servers;
+ }
+
+ /**
+ * Retrieve the simulation study list
+ *
+ * @return simulation studies
+ */
+ public Vector getSimulationStudies() {
+ return studies;
+ }
+
+ /**
+ * Get first unscheduled simulation
+ *
+ * @return Simulation first unscheduled simulation
+ * @see ducks.SimGeneratorInt
+ */
+ public synchronized SimulationInstance getFreeSimulation() {
+ if (currentStudy != null) {
+ return currentStudy.getPendingSimInstance();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Find a simulation study that has not been processed yet
+ *
+ * @return Unprocessed simulation study object, or null if none is available
+ */
+ private SimulationStudy getNextSimulationStudy() {
+ for (int i = 0; i < studies.size(); i++) {
+ SimulationStudy sst = (SimulationStudy) studies.get(i);
+ if (!sst.hasFinished() && sst != currentStudy) {
+ return sst;
+ }
+ }
+ // no unprocessed study found
+ return null;
+ }
+
+ /**
+ * Main method
+ *
+ * @param args
+ * Command line arguments for main. <li>-s / --simuconfig
+ * filename : specify a simulation study config file to use <li>
+ * -d / --ducksconfig filename : specify a ducks controller
+ * config file to use (default ducks/resources/ducks.properties)
+ * <li>-n / --nodb : run simulations without saving results to
+ * database <li>-l / --debuglevel : set basic debug level (log4j:
+ * INFO,WARN,DEBUG) <li>-p / --persist : do not exit controller,
+ * if all studies are processed (i.e. wait for new ones via
+ * remote proxy)
+ *
+ */
+ public static void main(String[] args) {
+
+ // Handling command line options & config properties
+ // ............................
+
+ CmdLineParser parser = new CmdLineParser();
+ CmdLineParser.Option optSimuConfig = parser.addStringOption('s', "simuconfig");
+ CmdLineParser.Option optDebugConfig = parser.addStringOption('d', "debugconfig");
+ CmdLineParser.Option optDebugLevel = parser.addStringOption('l', "debuglevel");
+ CmdLineParser.Option optPersist = parser.addIntegerOption('p', "persist");
+ CmdLineParser.Option optNoSave = parser.addBooleanOption('n', "nosave");
+
+ try {
+ parser.parse(args);
+ } catch (Exception e) {
+ System.out.println("Error parsing commandline options: " + args);
+ System.out.println("Usage: ");
+ System.out.println(" -s --simuconfig <simulation config file>");
+ System.out.println(" -p --persist (optional)");
+ System.out.println(" -n --nosave (optional)");
+ System.out.println(" -d --debugconfig <log4j config file> (optional)");
+ System.out.println(" -l --debuglevel <root log4j level> (optional)");
+ System.exit(99);
+ }
+
+ // Init log4j logging .................................................
+ // 1. Control root level (can be set as well)
+ // 2. Use detailed log4j properties, if given
+ BasicConfigurator.configure();
+
+ Level l = Level.ERROR;
+ if (parser.getOptionValue(optDebugLevel) != null) {
+ String loglevel = parser.getOptionValue(optDebugLevel).toString();
+ l = Level.toLevel(loglevel, l);
+ }
+ Logger.getRootLogger().setLevel(l);
+
+ if (parser.getOptionValue(optDebugConfig) != null) {
+ File f = new File(parser.getOptionValue(optDebugConfig).toString());
+
+ if (f.exists()) {
+ System.out.println("Starting logging with file " + f.getAbsoluteFile());
+ PropertyConfigurator.configure((parser.getOptionValue(optDebugConfig)).toString());
+ }
+ }
+
+ System.out.println("RootLogger is on level " + Logger.getRootLogger().getLevel());
+
+ // Loading configuration of simulation
+ // ...........................................
+ ExtendedProperties config = new ExtendedProperties();
+ String configFilename = (String) parser.getOptionValue(optSimuConfig);
+ if (configFilename == null) {
+ // if nothing given at the command line, try "config.properties"
+ configFilename = "config.properties";
+ }
+
+ try {
+ config.loadFromFile(configFilename);
+ } catch (IOException e) {
+ log.error("Loading DUCKS config file failed: given filename: " + configFilename + " working dir: "
+ + System.getProperty("user.dir") + " Exception: " + e.getMessage());
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ // Setup servers and storage
+ // .........................................................
+
+ DucksController dc = new DucksController();
+
+ try {
+ dc.servers.configure(config);
+ } catch (Exception e) {
+ log.error("Loading compute servers failed: " + e.getMessage());
+ e.printStackTrace();
+ System.exit(2);
+ }
+
+ // if no remote server is enabled, create a local server instead
+ if (dc.servers.count() == 0) {
+ log.warn("Could not find any enabled servers. Creating local server");
+ if (!dc.servers.createLocalServer(5550)) {
+ log.error("Could not create local server! Exiting ...");
+ System.exit(2);
+ }
+ }
+
+ boolean nosave = parser.getOptionValue(optNoSave) != null;
+ if (nosave) {
+ log.warn("Saving of results is disabled!");
+ } else {
+
+ try {
+ dc.storage.configure(config);
+ dc.storage.enable();
+ log.info("Result storage providers are initialized");
+
+ } catch (Exception e) {
+ log.error("Opening result storage failed: " + e.getMessage());
+ e.printStackTrace();
+ System.exit(3);
+ }
+ }
+
+ // Load simulation study ...............................................
+
+ try {
+ SimulationStudy simStudy = new SimulationStudy();
+ simStudy.configure(config);
+ dc.studies.add(simStudy);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error("Loading simulation study config failed: " + e.getMessage());
+ }
+
+ // Run simulations
+ // ............................................................
+
+ // set simulation study
+ if (dc.studies.size() > 0) {
+ dc.currentStudy = (SimulationStudy) dc.studies.get(0);
+
+ if ((!nosave) && dc.storage.backgroundSavingEnabled()) {
+ dc.storage.startBackgroundSaving(dc.currentStudy);
+ }
+ }
+
+ // enable the simulation server threads
+ dc.servers.enable();
+
+ // enable remote monitoring and control of the DucksController
+ // (currently only partly implemented)
+ if (config.getBooleanProperty(DucksController.CGF_PROXY_ENABLED, false)) {
+ dc.proxy = new ControllerProxy(dc);
+ }
+
+ // main loop
+ while (true) {
+
+ // Sleep for 10 seconds
+ try {
+ Thread.sleep(10000);
+ } catch (Exception e) {
+ }
+
+ if (dc.currentStudy != null) {
+ // we are currently processing a study
+ if (dc.currentStudy.hasFinished()) {
+ // current study has finished
+
+ if ((!nosave) && dc.storage.backgroundSavingEnabled()) {
+ dc.storage.stopBackgroundSaving();
+ }
+
+ // Save data to db (if no already done in while running)
+ if ((!nosave) && (!dc.storage.backgroundSavingEnabled())) {
+ try {
+ dc.storage.saveAll(dc.currentStudy);
+ } catch (Exception e) {
+ log.error("Failure with simulation study " + dc.currentStudy.getIdentifier());
+ log.error(" Saving results to database failed: " + e.getMessage());
+ log.error(" Waiting for user intervention ...");
+ e.printStackTrace();
+ // wait for user intervention ... (e.g. reparing the
+ // database)
+ continue;
+ }
+ }
+
+ // set currentStudy to null
+ // -> will select next available in next iteration of the
+ // main loop
+ // or quit, or idle
+ dc.currentStudy = null;
+ } else {
+ // current study still processing
+ // -> give some stats
+ int[] states = dc.currentStudy.getStateCount();
+ String st = "State of study " + dc.currentStudy.getIdentifier() + ": ";
+ st += "Pending: " + states[Simulation.PENDING] + ", ";
+ st += "Running: " + states[Simulation.RUNNING] + ", ";
+ st += "Finished: " + states[Simulation.FINISHED] + ", ";
+ st += "Flushed: " + states[Simulation.FLUSHED];
+ log.info(st);
+ }
+
+ } else {
+ // do we have unfinished studies in the queue?
+ SimulationStudy study = dc.getNextSimulationStudy();
+ if (study != null) {
+ // yeah, we have got one! -> set to current study and
+ // continue!
+ dc.currentStudy = study;
+ } else {
+ // not study any more? So, idle or exit
+ if (parser.getOptionValue(optPersist) == null) {
+ // ok, we do not want to persist, so exit loop here
+ break;
+ } else {
+ // well, we shall persist, so wait ...
+ log.info("Waiting for new simulation studies ...");
+ }
+ }
+ }
+
+ // Check if there are still processing servers available
+ if (dc.currentStudy != null && dc.servers.numberOfEnabledServers() == 0) {
+ log.warn("Number of enabled servers is zero, though simulations are pending!");
+
+ if (dc.proxy != null) {
+ // if we have a remote proxy, trust on user to re-activate
+ // servers again
+ log.warn("Waiting for manual server re-activation via remote controller");
+ } else {
+ // if not remote proxy exists, try to re-enable servers
+ int currentMin = 5;
+ while (currentMin > 0) {
+ log.debug("Trying to re-enable all servers in " + currentMin + " minutes");
+ currentMin--;
+ try {
+ Thread.sleep(60000);
+ } catch (Exception e) {
+ }
+ }
+ log.info("Re-enabling servers now ...");
+ dc.servers.enable();
+ }
+ }
+
+ }
+
+ // Clean up
+ // ...................................................................
+ dc.servers.disable();
+ dc.servers.stopLocalServer();
+
+ try {
+ if (dc.storage.backgroundSavingEnabled()) {
+ dc.storage.stopBackgroundSaving();
+ }
+ dc.storage.saveReadyResults();
+ dc.storage.disable();
+ } catch (DucksException e) {
+ log.warn("Storage provider disable problem: " + e.getMessage());
+ }
+
+ log.info("Terminating controller ...");
+ System.exit(0);
+ }
}
View
38 ducks/src/ducks/controller/DucksControllerModule.java
@@ -1,7 +1,7 @@
/*
* Ulm University DUCKS project
*
- * Author: Elmar Schoch <elmar.schoch@uni-ulm.de>
+ * Author: Elmar Schoch <elmar.schoch@uni-ulm.de>
*
* (C) Copyright 2007, Ulm University, all rights reserved.
*
@@ -12,32 +12,32 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
*/
package ducks.controller;
import ducks.misc.DucksException;
import ext.util.Configurable;
-public interface DucksControllerModule extends Configurable {
+public interface DucksControllerModule extends Configurable
+{
- /**
- * Enable the module. This method should activate operation of the module.
- * This may be opening a connection, a file, starting threads or whatever.
- *
- * @throws DucksException
- */
- public void enable() throws DucksException;
+ /**
+ * Enable the module. This method should activate operation of the module.
+ * This may be opening a connection, a file, starting threads or whatever.
+ *
+ * @throws DucksException
+ */
+ public void enable() throws DucksException;
- /**
- * Disable the module. This method should stop all operations of the module,
- * e.g. by closing open handles like files, and clean up the state of the
- * module
- *
- * @throws DuckExeption
- */
- public void disable() throws DucksException;
+ /**
+ * Disable the module. This method should stop all operations of the module,
+ * e.g. by closing open handles like files, and clean up the state of the
+ * module
+ *
+ * @throws DuckExeption
+ */
+ public void disable() throws DucksException;
}
View
234 ducks/src/ducks/controller/output/LogFile.java
@@ -1,7 +1,7 @@
/*
* Ulm University DUCKS project
*
- * Author: Elmar Schoch <elmar.schoch@uni-ulm.de>
+ * Author: Elmar Schoch <elmar.schoch@uni-ulm.de>
*
* (C) Copyright 2007, Ulm University, all rights reserved.
*
@@ -12,9 +12,8 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
*/
package ducks.controller.output;
@@ -38,124 +37,115 @@
* @author Elmar Schoch
*
*/
-public class LogFile implements StorageProvider {
-
- // log4j Logger
- private static Logger log = Logger.getLogger(LogFile.class.getName());
-
- // Configuration options relative to namespace
- public static final String CFG_FILENAME = "name";
- public static final String CFG_OPEN_APPEND = "append";
-
- private String filename;
- private boolean append;
-
- private PrintStream fileOutput;
-
- // Initialization, opening & closing
- // ..........................................
-
- /**
- * Configure module Whereas the name of the file is a mandatory parameter,
- * the open mode is optional. If append is not configured, data is appended
- * to an existing file by default.
- */
- public void configure(ExtendedProperties config) throws DucksException {
- filename = config.getProperty(CFG_FILENAME);
- append = config.getBooleanProperty(CFG_OPEN_APPEND, true);
- log.debug("Saving to file " + filename + ", append=" + append);
- }
-
- /**
- * Disable module. Flushes and closes the file.
- */
- public void disable() throws DucksException {
- if (fileOutput == null)
- return;
-
- try {
- fileOutput.flush();
- fileOutput.close();
- } catch (Exception e) {
-
- }
-
- }
-
- /**
- * Enable module. Opens the file for writing
- */
- public void enable() throws DucksException {
-
- try {
- // Create file outputstream to filename, in append mode
- FileOutputStream fileOut = new FileOutputStream(filename, append);
- fileOutput = new PrintStream(fileOut, true);
- } catch (Exception e) {
- throw new DucksException("Opening result log file failed: "
- + e.getMessage());
- }
- }
-
- /**
- * Save simulation to the file.
- */
- public void saveSimulation(Simulation simu) throws DucksException {
-
- // Save configuration first
- // what do we need to save
- ExtendedProperties config = simu.getSimuConfig();
- config = config.getFilteredSet(StorageProvider.CFG_EXCLUDE_PARAMS);
- String excParams = config
- .getProperty(StorageManager.CFG_EXCLUDE_PARAMS);
- String incParams = config
- .getProperty(StorageManager.CFG_INCLUDE_PARAMS);
- // NOTE: incParams and excParams may be null intentionally!!
- ExtendedProperties fields = config.getFilteredSet(incParams, excParams);
-
- fileOutput
- .println("Simulation ........................................");
- fileOutput.println("Study: " + simu.getSimStudy().getIdentifier());
- fileOutput.println("Simu: " + simu.getIdentifier());
- fileOutput
- .println("Configuration .....................................");
-
- fileOutput.println(fields.saveToSortedString("\n"));
- fileOutput.flush();
-
- // save results
- String excResults = config
- .getProperty(StorageManager.CFG_EXCLUDE_RESULTS);
- String incResults = config
- .getProperty(StorageManager.CFG_INCLUDE_RESULTS);
- Vector<SimulationInstance> instances = simu.getFinishedInstances();
-
- fileOutput
- .println("Results ...........................................");
- for (int i = 0; i < instances.size(); i++) {
- SimulationInstance si = instances.get(i);
- ExtendedProperties results = si.getResults();
- results = results.getFilteredSet(incResults, excResults);
- // save result values
- fileOutput.println("Instance: " + i);
- fileOutput.println(results.saveToSortedString("\n"));
- }
- fileOutput.flush();
- }
-
- /**
- * Save study information to file
- */
- public void saveSimulationStudy(SimulationStudy study)
- throws DucksException {
-
- fileOutput
- .println("Simulation Study ..........................................");
- fileOutput.println("Date: " + StringUtils.formatDateTime(new Date()));
- fileOutput.println("Description: " + study.getDescription());
- fileOutput.println("Identifier : " + study.getIdentifier());
-
- fileOutput.flush();
- }
+public class LogFile implements StorageProvider
+{
+
+ // log4j Logger
+ private static Logger log = Logger.getLogger(LogFile.class.getName());
+
+ // Configuration options relative to namespace
+ public static final String CFG_FILENAME = "name";
+ public static final String CFG_OPEN_APPEND = "append";
+
+ private String filename;
+ private boolean append;
+
+ private PrintStream fileOutput;
+
+ // Initialization, opening & closing
+ // ..........................................
+
+ /**
+ * Configure module Whereas the name of the file is a mandatory parameter,
+ * the open mode is optional. If append is not configured, data is appended
+ * to an existing file by default.
+ */
+ public void configure(ExtendedProperties config) throws DucksException {
+ filename = config.getProperty(CFG_FILENAME);
+ append = config.getBooleanProperty(CFG_OPEN_APPEND, true);
+ log.debug("Saving to file " + filename + ", append=" + append);
+ }
+
+ /**
+ * Disable module. Flushes and closes the file.
+ */
+ public void disable() throws DucksException {
+ if (fileOutput == null)
+ return;
+
+ try {
+ fileOutput.flush();
+ fileOutput.close();
+ } catch (Exception e) {
+
+ }
+
+ }
+
+ /**
+ * Enable module. Opens the file for writing
+ */
+ public void enable() throws DucksException {
+
+ try {
+ // Create file outputstream to filename, in append mode
+ FileOutputStream fileOut = new FileOutputStream(filename, append);
+ fileOutput = new PrintStream(fileOut, true);
+ } catch (Exception e) {
+ throw new DucksException("Opening result log file failed: " + e.getMessage());
+ }
+ }
+
+ /**
+ * Save simulation to the file.
+ */
+ public void saveSimulation(Simulation simu) throws DucksException {
+
+ // Save configuration first
+ // what do we need to save
+ ExtendedProperties config = simu.getSimuConfig();
+ config = config.getFilteredSet(StorageProvider.CFG_EXCLUDE_PARAMS);
+ String excParams = config.getProperty(StorageManager.CFG_EXCLUDE_PARAMS);
+ String incParams = config.getProperty(StorageManager.CFG_INCLUDE_PARAMS);
+ // NOTE: incParams and excParams may be null intentionally!!
+ ExtendedProperties fields = config.getFilteredSet(incParams, excParams);
+
+ fileOutput.println("Simulation ........................................");
+ fileOutput.println("Study: " + simu.getSimStudy().getIdentifier());
+ fileOutput.println("Simu: " + simu.getIdentifier());
+ fileOutput.println("Configuration .....................................");
+
+ fileOutput.println(fields.saveToSortedString("\n"));
+ fileOutput.flush();
+
+ // save results
+ String excResults = config.getProperty(StorageManager.CFG_EXCLUDE_RESULTS);
+ String incResults = config.getProperty(StorageManager.CFG_INCLUDE_RESULTS);
+ Vector<SimulationInstance> instances = simu.getFinishedInstances();
+
+ fileOutput.println("Results ...........................................");
+ for (int i = 0; i < instances.size(); i++) {
+ SimulationInstance si = instances.get(i);
+ ExtendedProperties results = si.getResults();
+ results = results.getFilteredSet(incResults, excResults);
+ // save result values
+ fileOutput.println("Instance: " + i);
+ fileOutput.println(results.saveToSortedString("\n"));
+ }
+ fileOutput.flush();
+ }
+
+ /**
+ * Save study information to file
+ */
+ public void saveSimulationStudy(SimulationStudy study) throws DucksException {
+
+ fileOutput.println("Simulation Study ..........................................");
+ fileOutput.println("Date: " + StringUtils.formatDateTime(new Date()));
+ fileOutput.println("Description: " + study.getDescription());
+ fileOutput.println("Identifier : " + study.getIdentifier());
+
+ fileOutput.flush();
+ }
}
View
781 ducks/src/ducks/controller/output/MySQLDatabase.java
@@ -1,7 +1,7 @@
/*
* Ulm University DUCKS project
*
- * Author: Elmar Schoch <elmar.schoch@uni-ulm.de>
+ * Author: Elmar Schoch <elmar.schoch@uni-ulm.de>
*
* (C) Copyright 2007, Ulm University, all rights reserved.
*
@@ -12,9 +12,8 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
*/
package ducks.controller.output;
@@ -39,409 +38,377 @@
import ext.util.ExtendedProperties;
import ext.util.StringUtils;
-public class MySQLDatabase implements StorageProvider {
-
- // log4j Logger
- private static Logger log = Logger.getLogger(MySQLDatabase.class.getName());
-
- // Database connection
- public static final String HOSTNAME = "hostname";
- public static final String PORT = "port";
- public static final String DATABASENAME = "dbname";
- public static final String AUTH_USERNAME = "username";
- public static final String AUTH_PASSWORD = "password";
-
- private String dbHost;
- private String dbName;
- private String dbPort = "3306"; // Default MySQL port
- private String dbUsername;
- private String dbPassword;
-
- private Connection dbConnection;
-
- // Structure of database
- // - table for simulation study (i.e. 1 entry per config file)
- // - table for simulation configurations (including all input parameters)
- // (1:n)
- // - table for simulation instances (included all output parameters) (1:n)
- // (should contain both foreign keys (of simu study and simu config)
-
- public static final String DB_SIMU_STUD = "simu_stud";
- public static final String DB_SIMU_CONF = "simu_conf";
- public static final String DB_SIMU_INST = "simu_inst";
-
- public static final String PRIMARY_KEY = "ID";
- public static final String STUDY_FOREIGN_KEY = "StudyID";
- public static final String CONFIG_FOREIGN_KEY = "ConfigID";
-
- // Relation between objects and IDs (since we only have IDs in the database)
- private HashMap<Object, Long> simuIds = new HashMap<Object, Long>();
-
- // Initialization, opening & closing
- // ..........................................
-
- public void configure(ExtendedProperties config) throws DucksException {
-
- dbHost = config.getProperty(HOSTNAME);
- String port = config.getProperty(PORT);
- if (port != null) {
- dbPort = port;
- }
- dbName = config.getProperty(DATABASENAME);
- dbUsername = config.getProperty(AUTH_USERNAME);
- dbPassword = config.getProperty(AUTH_PASSWORD);
-
- if (dbHost == null || dbName == null || dbUsername == null
- || dbPassword == null) {
- throw new DucksException(
- "Missing result database params in config file");
- }
-
- dbHost.trim();
- dbPort.trim();
- dbName.trim();
- dbUsername.trim();
- dbPassword.trim();
- }
-
- public void enable() throws DucksException {
-
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- dbConnection = DriverManager.getConnection("jdbc:mysql://" + dbHost
- + ":" + dbPort + "/" + dbName, dbUsername, dbPassword);
- } catch (Exception e) {
- dbConnection = null;
- throw new DucksException("Could not connect to database");
- }
- }
-
- public void disable() throws DucksException {
-
- try {
- if (!dbConnection.getAutoCommit()) {
- // can not commit, if auto commit is true
- dbConnection.commit();
- }
- dbConnection.close();
- dbConnection = null;
- } catch (SQLException e) {
- throw new DucksException("DB disconnect failed: " + e.getMessage());
- }
- }
-
- // Saving of data
- // .............................................................
- public void saveSimulationStudy(SimulationStudy study)
- throws DucksException {
-
- // if the object has been saved yet:
- Long id = simuIds.get(study);
- if (id != null)
- return;
-
- // check database connection
- if (dbConnection == null)
- throw new DucksException("No connection to db");
-
- // create structure, if required
- ExtendedProperties fields = new ExtendedProperties();
- fields.put("Description", "TEXT");
- fields.put("StartDate", "DATE");
-
- boolean consistent = checkDatabaseStructure(DB_SIMU_STUD, PRIMARY_KEY,
- null, fields, true, true);
- if (!consistent) {
- throw new DucksException(
- "Database structure not consistent. Skipping saving of study! ");
- }
-
- String query = "INSERT INTO " + DB_SIMU_STUD
- + " (Description,StartDate) VALUES ('" + study.getDescription()
- + "','" + StringUtils.formatDateTime(new Date()) + "');";
- long studyID = -1;
- log.debug("Inserting simulation run: " + query);
-
- try {
- Statement s = dbConnection.createStatement();
- s.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
- ResultSet rs = s.getGeneratedKeys();
-
- rs.next();
- studyID = rs.getLong(1);
- simuIds.put(study, new Long(studyID));
- log.debug("Successfully saved simulation study under ID=" + studyID);
- } catch (SQLException e) {
- throw new DucksException(
- "Simulation study could not be saved to MySQL database: "
- + e.getMessage());
- }
- }
-
- /**
- * Save simulation configuration, including the results of all contained
- * instances.
- *
- * @param simu
- * The simulation to save
- */
- public void saveSimulation(Simulation simu) throws DucksException {
-
- Long studyID = simuIds.get(simu.getSimStudy());
- log.debug("Saving simu under study ID " + studyID.toString());
- if (studyID == null) {
- log.error("Simulation study ID was not found when saving simulation config. Skipping saving");
- throw new DucksException(
- "Simulation study ID not found when saving simu config!");
- }
-
- // what do we need to save
- ExtendedProperties config = simu.getSimuConfig();
- String excParams = config
- .getProperty(StorageManager.CFG_EXCLUDE_PARAMS);
- String incParams = config
- .getProperty(StorageManager.CFG_INCLUDE_PARAMS);
- // NOTE: incParams and excParams may be null intentionally!!
- ExtendedProperties fields = config.getFilteredSet(incParams, excParams);
-
- // check structure
- checkDatabaseStructure(DB_SIMU_CONF, PRIMARY_KEY,
- new String[] { STUDY_FOREIGN_KEY }, fields, true, false);
-
- // save param values
- long simuID;
- Long simuIDObj;
- try {
- fields.put(STUDY_FOREIGN_KEY, studyID.toString());
- simuID = saveValues(DB_SIMU_CONF, fields);
- simuIDObj = new Long(simuID);
- log.debug("Successfully saved simulation configuration under ID="
- + simuID);
- simuIds.put(simu, simuIDObj);
- } catch (Exception e) {
- e.printStackTrace();
- throw new DucksException(
- "Simulation config could not be saved to DB: "
- + e.getMessage());
- }
-
- // save results
- String excResults = config
- .getProperty(StorageManager.CFG_EXCLUDE_RESULTS);
- String incResults = config
- .getProperty(StorageManager.CFG_INCLUDE_RESULTS);
- Vector<SimulationInstance> instances = simu.getFinishedInstances();
- for (int i = 0; i < instances.size(); i++) {
- SimulationInstance si = instances.get(i);
- ExtendedProperties results = si.getResults();
- if (results == null) {
- log.warn("Simulation instance " + si.getIdentifier()
- + " did not provide results!");
- continue;
- }
- results = results.getFilteredSet(incResults, excResults);
-
- checkDatabaseStructure(DB_SIMU_INST, PRIMARY_KEY, new String[] {
- STUDY_FOREIGN_KEY, CONFIG_FOREIGN_KEY }, results, true,
- false);
-
- // save result values
- try {
- // Caution: Adding 'long' values to the Properties object is
- // syntactically correct,
- // but leaves 'null' references instead of the values. Thus, add
- // as Long object or String
- results.put(STUDY_FOREIGN_KEY, studyID.toString());
- results.put(CONFIG_FOREIGN_KEY, simuIDObj.toString());
-
- saveValues(DB_SIMU_INST, results);
- } catch (Exception e) {
- e.printStackTrace();
- throw new DucksException(
- "Simulation instance could not be saved to DB: "
- + e.getMessage());
- }
-
- }
-
- }
-
- /**
- * Check the table structure of a certain table, and create fields, if
- * wanted.
- *
- * @param table
- * The table to check. Will also be created, if addDynamically is
- * true
- * @param priKeyField
- * Name of the primary key field, if table needs to be created
- * @param foreignKeys
- * Names of foreign keys, that will be also created as
- * bigint(20), when the table needs to be created
- * @param fields
- * Properties that contain the fields to check. Only the names
- * will be taken, unless the <code>propertyValueIsDataType</code>
- * indicates to use the value as corresponding data type
- * @param addDynamically
- * Add table and fields, if they are not there yet. otherwise
- * return false.
- * @param propertyValueIsDataType
- * Use the value of the fields property as datatype, if true
- */
- private boolean checkDatabaseStructure(String table, String priKeyField,
- String[] foreignKeys, ExtendedProperties fields,
- boolean addDynamically, boolean propertyValueIsDataType) {
-
- // check if table is available
- try {
- DatabaseMetaData dbmd = dbConnection.getMetaData();
- String[] objectCategories = { "TABLE" };
- ResultSet tabs = dbmd.getTables(dbName, null, null,
- objectCategories);
-
- boolean found = false;
- while (tabs.next()) {
- String tab = tabs.getString("TABLE_NAME");
- log.debug("Found table: " + tab);
- if (tab.equals(table))
- found = true;
- }
-
- if (!found) {
- log.info("checkDB: table " + table + " not found");
- if (addDynamically) {
- // table not found, instant adding wanted
- Statement s = dbConnection.createStatement();
- String query = "CREATE TABLE `" + table + "` ("
- + priKeyField
- + " bigint(20) unsigned NOT NULL auto_increment, ";
- if (foreignKeys != null) {
- for (int i = 0; i < foreignKeys.length; i++) {
- query += foreignKeys[i]
- + " bigint(20) unsigned NOT NULL, ";
- }
- }
- query += "PRIMARY KEY (" + priKeyField
- + ") ) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
- log.debug("Executing: " + query);
- try {
- s.execute(query);
- } catch (SQLException sqle) {
- log.debug("Executing query failed: " + query
- + " Exception: " + sqle.getMessage());
- return false;
- }
-
- } else {
- // table not found, no instant adding wanted
- log.debug("checkDB: table "
- + table
- + " not found, dynamic adding not wanted -> DB inconsistent");
- return false;
- }
- } else {
- // table was found
- log.debug("checkDB: table " + table + " already exists");
- }
-
- } catch (Exception e) {
- log.debug("Checking for tables failed: " + e.getMessage());
- return false;
- }
-
- // check fields .......................................
- log.debug("CheckDB: Checking fields ...");
- ExtendedProperties wantedfields = fields.cloneProperties();
-
- try {
- Statement s = dbConnection.createStatement();
- ResultSet cols = s.executeQuery("SELECT * FROM `" + table
- + "` WHERE 1=2");
- ResultSetMetaData rsmd = cols.getMetaData();
- for (int i = 1; i <= rsmd.getColumnCount(); i++) {
- String col = rsmd.getColumnName(i);
- log.debug("CheckDB: Found column: " + col);
- wantedfields.remove(col);
- }
- } catch (Exception e) {
- log.warn("Checking for table columns failed: " + e.getMessage());
- return false;
- }
-
- // now, only the fields remain which are not in the table
- if (addDynamically) {
- // create columns, that were not found
- Enumeration newFields = wantedfields.keys();
- while (newFields.hasMoreElements()) {
- String fieldname = (String) newFields.nextElement();
- String datatype = propertyValueIsDataType ? wantedfields
- .getProperty(fieldname) : "TEXT";
- try {
- Statement s = dbConnection.createStatement();
- s.execute("ALTER TABLE `" + table + "` ADD COLUMN `"
- + fieldname + "` " + datatype + ";");
- } catch (Exception e) {
- e.printStackTrace();
- log.warn("Could not add column " + fieldname + " ("
- + datatype + ") to table " + table + ": "
- + e.getMessage());
- return false;
- }
- }
- } else {
- if (wantedfields.size() > 0) {
- // have fields not in the table, but do not want to add
- // dynamically
- log.debug("CheckDB: Columns were noet found, no dynamic adding wanted - "
- + wantedfields.toString());
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Save a properties list to the database. CAUTION: Only valid properties
- * are allowed as column names, and values must not contain ' signs!!
- * Otherwise, the query will fail!
- *
- * @param table
- * The table to add the data
- * @param props
- * The properties where the key is used as column name, the value
- * as row value
- * @return The ID of the row in the rable
- * @throws Exception
- */
- private long saveValues(String table, ExtendedProperties props)
- throws Exception {
-
- // Build query
- // Note: Tables must be embraced by ` signs, but values must not!
- // Instead, values need ' or " signs
- //
- String q = "INSERT INTO " + table + " SET ";
- Enumeration fields = props.keys();
- while (fields.hasMoreElements()) {
- String name = (String) fields.nextElement();
- String val = props.getProperty(name);
- q += "`" + name + "`='" + val + "'";
- if (fields.hasMoreElements()) {
- q += ", ";
- }
- }
- q += ";";
-
- log.debug("Execute: " + q);
-
- Statement s = dbConnection.createStatement();
- s.execute(q, Statement.RETURN_GENERATED_KEYS);
-
- ResultSet rs = s.getGeneratedKeys();
- rs.next();
- long configID = rs.getLong(1);
- return configID;
- }
+public class MySQLDatabase implements StorageProvider
+{
+
+ // log4j Logger
+ private static Logger log = Logger.getLogger(MySQLDatabase.class.getName());
+
+ // Database connection
+ public static final String HOSTNAME = "hostname";
+ public static final String PORT = "port";
+ public static final String DATABASENAME = "dbname";
+ public static final String AUTH_USERNAME = "username";
+ public static final String AUTH_PASSWORD = "password";
+
+ private String dbHost;
+ private String dbName;
+ private String dbPort = "3306"; // Default
+ // MySQL
+ // port
+ private String dbUsername;
+ private String dbPassword;
+
+ private Connection dbConnection;
+
+ // Structure of database
+ // - table for simulation study (i.e. 1 entry per config file)
+ // - table for simulation configurations (including all input parameters)
+ // (1:n)
+ // - table for simulation instances (included all output parameters) (1:n)
+ // (should contain both foreign keys (of simu study and simu config)
+
+ public static final String DB_SIMU_STUD = "simu_stud";
+ public static final String DB_SIMU_CONF = "simu_conf";
+ public static final String DB_SIMU_INST = "simu_inst";
+
+ public static final String PRIMARY_KEY = "ID";
+ public static final String STUDY_FOREIGN_KEY = "StudyID";
+ public static final String CONFIG_FOREIGN_KEY = "ConfigID";
+
+ // Relation between objects and IDs (since we only have IDs in the database)
+ private HashMap<Object, Long> simuIds = new HashMap<Object, Long>();
+
+ // Initialization, opening & closing
+ // ..........................................
+
+ public void configure(ExtendedProperties config) throws DucksException {
+
+ dbHost = config.getProperty(HOSTNAME);
+ String port = config.getProperty(PORT);
+ if (port != null) {
+ dbPort = port;
+ }
+ dbName = config.getProperty(DATABASENAME);
+ dbUsername = config.getProperty(AUTH_USERNAME);
+ dbPassword = config.getProperty(AUTH_PASSWORD);
+
+ if (dbHost == null || dbName == null || dbUsername == null || dbPassword == null) {
+ throw new DucksException("Missing result database params in config file");