source: java/main/src/main/java/com/framsticks/experiment/SimulatorRange.java @ 107

Last change on this file since 107 was 107, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • add SimultorProviders? hierarchy
  • start Framsticks server over SSH
  • FJF compatible with Framsticks 4.0rc3
  • reading and writing of standard.expt
  • a proof-of-concept implementation of StandardExperiment?

CHANGELOG:
Optionally return FreeAccess? from registry.

Add SimulatorRange?.

StandardExperiment? with genotypes circulation.

Automate registration around StandardState?.

More improvements to StandardExperiment?.

Skeleton version of StandardExperiment?.

Test saving of StandardState?.

Standard experiment state is being loaded.

More development towards StandardState? reading.

Work on reading standard experiment state.

Add classes for standard experiment.

Update example standard.expt

Add FreeAccess? and FreeObject?.

Made compatible with version 4.0rc3

Change deserialization policy.

Improve SSH support.

Working running simulator over SSH.

Fix joining bug in Experiment.

Working version of SimulatorRunner?.

Add more SimulatorProviders?.

Working PrimeExperimentTest? with 4.0rc3

Add references to deserialization.

Add OpaqueObject? and it's serialization.

Add deserialization of dictionaries.

Partial implementation of deserialization.

Add more tests for deserialization.

Prepare tests for deserialization.

Add proper result to prime experiment test.

Minor fixes to simulators providers.

Draft version of SimulatorProvider?.

Add SimulatorProvider? interface.

File size: 2.4 KB
Line 
1package com.framsticks.experiment;
2
3import java.util.ArrayList;
4import java.util.Iterator;
5import java.util.List;
6
7import org.apache.logging.log4j.Logger;
8import org.apache.logging.log4j.LogManager;
9
10import com.framsticks.communication.Address;
11import com.framsticks.params.annotations.FramsClassAnnotation;
12import com.framsticks.params.annotations.ParamAnnotation;
13import com.framsticks.params.types.UniversalParam;
14import com.framsticks.util.dispatching.FutureHandler;
15import com.framsticks.util.dispatching.JoinableCollection;
16
17@FramsClassAnnotation
18public class SimulatorRange extends JoinableCollection<SimulatorProvider> implements SimulatorProvider {
19        private static final Logger log = LogManager.getLogger(Experiment.class);
20
21
22        protected List<String> hosts = new ArrayList<>();
23        protected List<Integer> ports = new ArrayList<>();
24
25        protected Iterator<Address> addresses;
26        protected boolean run = true;
27
28        @Override
29        public String getName() {
30                return "simulator range";
31        }
32
33        @Override
34        public void provideSimulator(final SimulatorSpecification specification, final FutureHandler<Simulator> future) {
35                if (addresses == null) {
36                        log.info("providing simulators from set: {} X {}", hosts, ports);
37
38                        List<Address> list = new ArrayList<Address>();
39                        for (String host : hosts) {
40                                for (Integer port : ports) {
41                                        list.add(new Address(host, port));
42                                }
43                        }
44                        addresses = list.iterator();
45                }
46
47                if (!addresses.hasNext()) {
48                        future.pass(null);
49                        return;
50                }
51                Address address = addresses.next();
52                SingleSimulatorProvider provider = (run ? new SimulatorRunner() : new SimulatorConnector());
53                provider.setAddress(address);
54                add(provider);
55                provider.provideSimulator(specification, future);
56        }
57
58        /**
59         * @return the hosts
60         */
61        @ParamAnnotation(paramType = UniversalParam.class)
62        public List<String> getHosts() {
63                return hosts;
64        }
65
66        /**
67         * @param hosts the hosts to set
68         */
69        @ParamAnnotation
70        public void setHosts(List<String> hosts) {
71                this.hosts = hosts;
72        }
73
74        /**
75         * @return the ports
76         */
77        @ParamAnnotation(paramType = UniversalParam.class)
78        public List<Integer> getPorts() {
79                return ports;
80        }
81
82        /**
83         * @param ports the ports to set
84         */
85        @ParamAnnotation
86        public void setPorts(List<Integer> ports) {
87                this.ports = ports;
88        }
89
90        /**
91         * @return the run
92         */
93        @ParamAnnotation
94        public boolean getRun() {
95                return run;
96        }
97
98        /**
99         * @param run the run to set
100         */
101        @ParamAnnotation
102        public void setRun(boolean run) {
103                this.run = run;
104        }
105}
Note: See TracBrowser for help on using the repository browser.