use of org.apache.ignite.cache.CacheMode in project ignite by apache.
the class GridCacheProcessor method onKernalStart.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
public void onKernalStart(boolean activeOnStart) throws IgniteCheckedException {
ClusterNode locNode = ctx.discovery().localNode();
try {
boolean checkConsistency = !ctx.config().isDaemon() && !getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK);
if (checkConsistency)
checkConsistency();
cachesInfo.onKernalStart(checkConsistency);
boolean currStatus = ctx.state().active();
// which were received on join.
if (!ctx.isDaemon() && currStatus && !activeOnStart) {
List<CacheConfiguration> tmpCacheCfg = new ArrayList<>();
for (CacheConfiguration conf : ctx.config().getCacheConfiguration()) {
assert conf.getName() != null;
for (DynamicCacheDescriptor desc : cacheDescriptors()) {
CacheConfiguration c = desc.cacheConfiguration();
IgnitePredicate filter = c.getNodeFilter();
if (c.getName().equals(conf.getName()) && ((desc.receivedOnDiscovery() && CU.affinityNode(locNode, filter)) || CU.isSystemCache(c.getName()))) {
tmpCacheCfg.add(c);
break;
}
}
}
if (!tmpCacheCfg.isEmpty()) {
CacheConfiguration[] newCacheCfg = new CacheConfiguration[tmpCacheCfg.size()];
tmpCacheCfg.toArray(newCacheCfg);
ctx.config().setCacheConfiguration(newCacheCfg);
}
activeOnStart = currStatus;
}
if (activeOnStart && !ctx.clientNode() && !ctx.isDaemon())
sharedCtx.database().lock();
// Must start database before start first cache.
sharedCtx.database().onKernalStart(false);
ctx.query().onCacheKernalStart();
for (GridCacheSharedManager<?, ?> mgr : sharedCtx.managers()) {
if (sharedCtx.database() != mgr)
mgr.onKernalStart(false);
}
} finally {
cacheStartedLatch.countDown();
}
// Escape if start active on start false
if (!activeOnStart)
return;
if (!ctx.config().isDaemon())
ctx.cacheObjects().onUtilityCacheStarted();
ctx.service().onUtilityCacheStarted();
final AffinityTopologyVersion startTopVer = new AffinityTopologyVersion(ctx.discovery().localJoinEvent().topologyVersion(), 0);
final List<IgniteInternalFuture> syncFuts = new ArrayList<>(caches.size());
sharedCtx.forAllCaches(new CIX1<GridCacheContext>() {
@Override
public void applyx(GridCacheContext cctx) throws IgniteCheckedException {
CacheConfiguration cfg = cctx.config();
if (cctx.affinityNode() && cfg.getRebalanceMode() == SYNC && startTopVer.equals(cctx.startTopologyVersion())) {
CacheMode cacheMode = cfg.getCacheMode();
if (cacheMode == REPLICATED || (cacheMode == PARTITIONED && cfg.getRebalanceDelay() >= 0))
// Need to wait outside to avoid a deadlock
syncFuts.add(cctx.preloader().syncFuture());
}
}
});
for (int i = 0, size = syncFuts.size(); i < size; i++) syncFuts.get(i).get();
assert ctx.config().isDaemon() || caches.containsKey(CU.UTILITY_CACHE_NAME) : "Utility cache should be started";
if (!ctx.clientNode() && !ctx.isDaemon())
addRemovedItemsCleanupTask(Long.getLong(IGNITE_CACHE_REMOVED_ENTRIES_TTL, 10_000));
}
use of org.apache.ignite.cache.CacheMode in project ignite by apache.
the class ParametersTest method testEnumVariations.
/**
* @throws Exception If failed.
*/
public void testEnumVariations() throws Exception {
ConfigParameter<CacheConfiguration>[] modes = Parameters.enumParameters("setCacheMode", CacheMode.class);
assertEquals(CacheMode.values().length, modes.length);
Set<CacheMode> res = new HashSet<>();
for (ConfigParameter<CacheConfiguration> modeApplier : modes) {
CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
modeApplier.apply(cfg);
CacheMode mode = cfg.getCacheMode();
res.add(mode);
System.out.println(">>> " + mode);
}
assertEquals(modes.length, res.size());
}
use of org.apache.ignite.cache.CacheMode in project ignite by apache.
the class ParametersTest method testEnumVariationsWithNull.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("unchecked")
public void testEnumVariationsWithNull() throws Exception {
ConfigParameter<CacheConfiguration>[] cfgParam = Parameters.enumParameters(true, "setCacheMode", CacheMode.class);
assertEquals(CacheMode.values().length + 1, cfgParam.length);
cfgParam[0] = null;
Set<CacheMode> set = new HashSet<>();
for (int i = 1; i < cfgParam.length; i++) {
ConfigParameter<CacheConfiguration> modeApplier = cfgParam[i];
CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
modeApplier.apply(cfg);
CacheMode mode = cfg.getCacheMode();
set.add(mode);
System.out.println(">>> " + mode);
}
assertEquals(CacheMode.values().length, set.size());
}
use of org.apache.ignite.cache.CacheMode in project ignite by apache.
the class GridTopologyCommandHandler method createNodeBean.
/**
* Creates node bean out of grid node. Notice that cache attribute is handled separately.
*
* @param node Grid node.
* @param mtr {@code true} to add metrics.
* @param attr {@code true} to add attributes.
* @return Grid Node bean.
*/
private GridClientNodeBean createNodeBean(ClusterNode node, boolean mtr, boolean attr) {
assert node != null;
GridClientNodeBean nodeBean = new GridClientNodeBean();
nodeBean.setNodeId(node.id());
nodeBean.setConsistentId(node.consistentId());
nodeBean.setTcpPort(attribute(node, ATTR_REST_TCP_PORT, 0));
nodeBean.setTcpAddresses(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_ADDRS)));
nodeBean.setTcpHostNames(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_HOST_NAMES)));
GridCacheProcessor cacheProc = ctx.cache();
Map<String, CacheMode> nodeCaches = ctx.discovery().nodeCaches(node);
Collection<GridClientCacheBean> caches = new ArrayList<>(nodeCaches.size());
for (String cacheName : nodeCaches.keySet()) caches.add(createCacheBean(cacheProc.cacheConfiguration(cacheName)));
nodeBean.setCaches(caches);
if (mtr) {
ClusterMetrics metrics = node.metrics();
GridClientNodeMetricsBean metricsBean = new GridClientNodeMetricsBean();
metricsBean.setStartTime(metrics.getStartTime());
metricsBean.setAverageActiveJobs(metrics.getAverageActiveJobs());
metricsBean.setAverageCancelledJobs(metrics.getAverageCancelledJobs());
metricsBean.setAverageCpuLoad(metrics.getAverageCpuLoad());
metricsBean.setAverageJobExecuteTime(metrics.getAverageJobExecuteTime());
metricsBean.setAverageJobWaitTime(metrics.getAverageJobWaitTime());
metricsBean.setAverageRejectedJobs(metrics.getAverageRejectedJobs());
metricsBean.setAverageWaitingJobs(metrics.getAverageWaitingJobs());
metricsBean.setCurrentActiveJobs(metrics.getCurrentActiveJobs());
metricsBean.setCurrentCancelledJobs(metrics.getCurrentCancelledJobs());
metricsBean.setCurrentCpuLoad(metrics.getCurrentCpuLoad());
metricsBean.setCurrentGcCpuLoad(metrics.getCurrentGcCpuLoad());
metricsBean.setCurrentDaemonThreadCount(metrics.getCurrentDaemonThreadCount());
metricsBean.setCurrentIdleTime(metrics.getCurrentIdleTime());
metricsBean.setCurrentJobExecuteTime(metrics.getCurrentJobExecuteTime());
metricsBean.setCurrentJobWaitTime(metrics.getCurrentJobWaitTime());
metricsBean.setCurrentRejectedJobs(metrics.getCurrentRejectedJobs());
metricsBean.setCurrentThreadCount(metrics.getCurrentThreadCount());
metricsBean.setCurrentWaitingJobs(metrics.getCurrentWaitingJobs());
metricsBean.setHeapMemoryCommitted(metrics.getHeapMemoryCommitted());
metricsBean.setHeapMemoryInitialized(metrics.getHeapMemoryInitialized());
metricsBean.setHeapMemoryMaximum(metrics.getHeapMemoryMaximum());
metricsBean.setHeapMemoryUsed(metrics.getHeapMemoryUsed());
metricsBean.setLastDataVersion(metrics.getLastDataVersion());
metricsBean.setLastUpdateTime(metrics.getLastUpdateTime());
metricsBean.setMaximumActiveJobs(metrics.getMaximumActiveJobs());
metricsBean.setMaximumCancelledJobs(metrics.getMaximumCancelledJobs());
metricsBean.setMaximumJobExecuteTime(metrics.getMaximumJobExecuteTime());
metricsBean.setMaximumJobWaitTime(metrics.getMaximumJobWaitTime());
metricsBean.setMaximumRejectedJobs(metrics.getMaximumRejectedJobs());
metricsBean.setMaximumThreadCount(metrics.getMaximumThreadCount());
metricsBean.setMaximumWaitingJobs(metrics.getMaximumWaitingJobs());
metricsBean.setNodeStartTime(metrics.getNodeStartTime());
metricsBean.setNonHeapMemoryCommitted(metrics.getNonHeapMemoryCommitted());
metricsBean.setNonHeapMemoryInitialized(metrics.getNonHeapMemoryInitialized());
metricsBean.setNonHeapMemoryMaximum(metrics.getNonHeapMemoryMaximum());
metricsBean.setNonHeapMemoryUsed(metrics.getNonHeapMemoryUsed());
metricsBean.setStartTime(metrics.getStartTime());
metricsBean.setTotalCancelledJobs(metrics.getTotalCancelledJobs());
metricsBean.setTotalCpus(metrics.getTotalCpus());
metricsBean.setTotalExecutedJobs(metrics.getTotalExecutedJobs());
metricsBean.setTotalIdleTime(metrics.getTotalIdleTime());
metricsBean.setTotalRejectedJobs(metrics.getTotalRejectedJobs());
metricsBean.setTotalStartedThreadCount(metrics.getTotalStartedThreadCount());
metricsBean.setTotalExecutedTasks(metrics.getTotalExecutedTasks());
metricsBean.setSentMessagesCount(metrics.getSentMessagesCount());
metricsBean.setSentBytesCount(metrics.getSentBytesCount());
metricsBean.setReceivedMessagesCount(metrics.getReceivedMessagesCount());
metricsBean.setReceivedBytesCount(metrics.getReceivedBytesCount());
metricsBean.setUpTime(metrics.getUpTime());
nodeBean.setMetrics(metricsBean);
}
if (attr) {
Map<String, Object> attrs = new HashMap<>(node.attributes());
attrs.remove(ATTR_CACHE);
attrs.remove(ATTR_TX_CONFIG);
attrs.remove(ATTR_SECURITY_SUBJECT);
attrs.remove(ATTR_SECURITY_SUBJECT_V2);
attrs.remove(ATTR_SECURITY_CREDENTIALS);
attrs.remove(ATTR_BINARY_CONFIGURATION);
attrs.remove(ATTR_NODE_CONSISTENT_ID);
for (Iterator<Map.Entry<String, Object>> i = attrs.entrySet().iterator(); i.hasNext(); ) {
Map.Entry<String, Object> e = i.next();
if (!e.getKey().startsWith("org.apache.ignite.") && !e.getKey().startsWith("plugins.") && System.getProperty(e.getKey()) == null) {
i.remove();
continue;
}
if (e.getValue() != null) {
if (e.getValue().getClass().isEnum() || e.getValue() instanceof InetAddress)
e.setValue(e.getValue().toString());
else if (e.getValue().getClass().isArray())
i.remove();
}
}
nodeBean.setAttributes(attrs);
}
return nodeBean;
}
Aggregations