Skip to content

Commit

Permalink
IGNITE-6670 Web Agent: Improved demo startup.
Browse files Browse the repository at this point in the history
  • Loading branch information
akuznetsov-os committed Oct 30, 2017
1 parent 67859f4 commit b4bd20e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteServices;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.MemoryConfiguration;
import org.apache.ignite.configuration.MemoryPolicyConfiguration;
import org.apache.ignite.console.demo.service.DemoCachesLoadService;
import org.apache.ignite.console.demo.service.DemoComputeLoadService;
import org.apache.ignite.console.demo.service.DemoRandomCacheLoadService;
Expand All @@ -53,6 +53,7 @@
import static org.apache.ignite.IgniteSystemProperties.IGNITE_PERFORMANCE_SUGGESTIONS_DISABLED;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_QUIET;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER;
import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_DATA_REGION_INITIAL_SIZE;
import static org.apache.ignite.console.demo.AgentDemoUtils.newScheduledThreadPool;
import static org.apache.ignite.events.EventType.EVTS_DISCOVERY;
import static org.apache.ignite.internal.visor.util.VisorTaskUtils.VISOR_TASK_EVTS;
Expand Down Expand Up @@ -132,15 +133,16 @@ private static IgniteConfiguration igniteConfiguration(int basePort, int gridIdx
cfg.setGridLogger(new Slf4jLogger(log));
cfg.setMetricsLogFrequency(0);

MemoryConfiguration memCfg = new MemoryConfiguration();
DataRegionConfiguration dataRegCfg = new DataRegionConfiguration();
dataRegCfg.setName("demo");
dataRegCfg.setMetricsEnabled(true);
dataRegCfg.setMaxSize(DFLT_DATA_REGION_INITIAL_SIZE);

MemoryPolicyConfiguration memPlc = new MemoryPolicyConfiguration();
memPlc.setName("demo");
memPlc.setMetricsEnabled(true);
DataStorageConfiguration dataStorageCfg = new DataStorageConfiguration();
dataStorageCfg.setDefaultDataRegionConfiguration(dataRegCfg);
dataStorageCfg.setSystemRegionMaxSize(DFLT_DATA_REGION_INITIAL_SIZE);

memCfg.setMemoryPolicies(memPlc);

cfg.setMemoryConfiguration(memCfg);
cfg.setDataStorageConfiguration(dataStorageCfg);

if (client)
cfg.setClientMode(true);
Expand All @@ -157,10 +159,10 @@ private static void deployServices(IgniteServices services) {
services.deployMultiple("Demo service: Multiple instances", new DemoServiceMultipleInstances(), 7, 3);
services.deployNodeSingleton("Demo service: Node singleton", new DemoServiceNodeSingleton());
services.deployClusterSingleton("Demo service: Cluster singleton", new DemoServiceClusterSingleton());
services.deployClusterSingleton("Demo caches load service", new DemoCachesLoadService(20));
services.deployKeyAffinitySingleton("Demo service: Key affinity singleton",
new DemoServiceKeyAffinity(), DemoCachesLoadService.CAR_CACHE_NAME, "id");

services.deployClusterSingleton("Demo caches load service", new DemoCachesLoadService(20));
services.deployNodeSingleton("RandomCache load service", new DemoRandomCacheLoadService(20));

services.deployMultiple("Demo service: Compute load", new DemoComputeLoadService(), 2, 1);
Expand Down Expand Up @@ -195,8 +197,10 @@ public static CountDownLatch tryStart() {
int idx = cnt.incrementAndGet();
int port = basePort.get();

IgniteEx ignite = null;

try {
IgniteEx ignite = (IgniteEx)Ignition.start(igniteConfiguration(port, idx, false));
ignite = (IgniteEx)Ignition.start(igniteConfiguration(port, idx, false));

if (idx == 0) {
Collection<String> jettyAddrs = ignite.localNode().attribute(ATTR_REST_JETTY_ADDRS);
Expand All @@ -219,8 +223,6 @@ public static CountDownLatch tryStart() {
demoUrl = String.format("http://%s:%d", jettyHost, jettyPort);

initLatch.countDown();

deployServices(ignite.services(ignite.cluster().forServers()));
}
}
catch (Throwable e) {
Expand All @@ -234,13 +236,15 @@ public static CountDownLatch tryStart() {
}
finally {
if (idx == NODE_CNT) {
deployServices(ignite.services(ignite.cluster().forServers()));

log.info("DEMO: All embedded nodes for demo successfully started");

execSrv.shutdown();
}
}
}
}, 1, 10, TimeUnit.SECONDS);
}, 1, 5, TimeUnit.SECONDS);
}

return initLatch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ public DemoCachesLoadService(int cnt) {
}, 10, 3, TimeUnit.SECONDS);
}


/**
* Create base cache configuration.
*
Expand All @@ -208,7 +207,7 @@ private static CacheConfiguration cacheConfiguration(String name) {
ccfg.setQueryDetailMetricsSize(10);
ccfg.setStatisticsEnabled(true);
ccfg.setSqlFunctionClasses(SQLFunctions.class);
ccfg.setMemoryPolicyName("demo");
ccfg.setDataRegionName("demo");

return ccfg;
}
Expand Down

0 comments on commit b4bd20e

Please sign in to comment.