/** * Reconstructs object on unmarshalling. * * @return Reconstructed object. * @throws ObjectStreamException Thrown in case of unmarshalling error. */ protected Object readResolve() throws ObjectStreamException { try { return GridGainEx.gridx(stash.get()).context(); } catch (IllegalStateException e) { throw U.withCause(new InvalidObjectException(e.getMessage()), e); } finally { stash.remove(); } }
validateCommon(cfg); ackAsciiLogo(); ackNodeId(); ackConfigUrl(); ackDaemon(); ackOsInfo(); ackLanguageRuntime(); ackRemoteManagement(); ackVmArguments(rtBean); ackClassPaths(rtBean); ackSystemProperties(); ackEnvironmentVariables(); ackSmtpConfiguration(); ackCacheConfiguration(); ackP2pConfiguration(); logNodeUserAttributes(); ackSpis(); Map<String, Object> attrs = createNodeAttributes(cfg, BUILD_TSTAMP_STR); setKernalContext(ctx); startProcessor(ctx, rsrcProc, attrs); notifyLifecycleBeans(BEFORE_GRID_START);
/** {@inheritDoc} */ @Override public GridTuple3<GridAffinityMessage, GridAffinityMessage, GridAffinityAssignment> call() throws Exception { assert grid != null; assert log != null; GridKernal kernal = ((GridKernal)grid); GridCacheContext<Object, Object> cctx = kernal.internalCache(cacheName).context(); assert cctx != null; GridKernalContext ctx = kernal.context(); return F.t( affinityMessage(ctx, cctx.config().getAffinity()), affinityMessage(ctx, cctx.config().getAffinityMapper()), new GridAffinityAssignment(topVer, cctx.affinity().assignments(topVer))); }
GridKernal grid0 = new GridKernal(startCtx.springContext()); grid0.start(myCfg, utilityCacheExecSvc, new CA() { @Override public void apply() { startLatch.countDown();
/** * Reconstructs object on unmarshalling. * * @return Reconstructed object. * @throws ObjectStreamException Thrown in case of unmarshalling error. */ protected Object readResolve() throws ObjectStreamException { try { GridKernal g = GridGainEx.gridx(gridName); return ids != null ? new GridProjectionAdapter(g, g.context(), subjId, ids) : p != null ? new GridProjectionAdapter(g, g.context(), subjId, p) : g; } catch (IllegalStateException e) { throw U.withCause(new InvalidObjectException(e.getMessage()), e); } }
/** * * @param id Uniq query result id. */ private void scheduleResultSetHolderRemoval(final String id) { ((GridKernal)g).context().timeout().addTimeoutObject(new GridTimeoutObjectAdapter(RMV_DELAY) { @Override public void onTimeout() { GridNodeLocalMap<String, VisorFutureResultSetHolder> storage = g.nodeLocalMap(); VisorFutureResultSetHolder<?> t = storage.get(id); if (t != null) { // If future was accessed since last scheduling, set access flag to false and reschedule. if (t.accessed()) { t.accessed(false); scheduleResultSetHolderRemoval(id); } else storage.remove(id); // Remove stored future otherwise. } } }); }
/** * Schedule cleanup process for events monitoring. * @param g grid. */ private void scheduleCleanupJob(final GridEx g) { ((GridKernal)g).context().timeout().addTimeoutObject(new GridTimeoutObjectAdapter(CLEANUP_TIMEOUT) { @Override public void onTimeout() { synchronized(listenVisor) { if (tryDisableEvents(g)) { for (String visorKey : listenVisor.keySet()) listenVisor.put(visorKey, false); scheduleCleanupJob(g); } else cleanupStopped = true; } } }); }
/** * * @param id Unique query result id. */ private void scheduleResultSetHolderRemoval(final String id) { ((GridKernal)g).context().timeout().addTimeoutObject(new GridTimeoutObjectAdapter(RMV_DELAY) { @Override public void onTimeout() { GridNodeLocalMap<String, VisorFutureResultSetHolder> storage = g.nodeLocalMap(); VisorFutureResultSetHolder<?> t = storage.get(id); if (t != null) { // If future was accessed since last scheduling, set access flag to false and reschedule. if (t.accessed()) { t.accessed(false); scheduleResultSetHolderRemoval(id); } else storage.remove(id); // Remove stored future otherwise. } } }); }
/** {@inheritDoc} */ @Override public Void call() throws GridException { GridCacheAdapter cache = ((GridKernal)grid).context().cache().internalCache(cacheName); assert cache != null; cache.context().dataStructures().removeSetData(setId, topVer); return null; }
/** {@inheritDoc} */ @Override public Void call() throws GridException { GridCacheAdapter cache = ((GridKernal)grid).context().cache().internalCache(cacheName); assert cache != null; cache.context().dataStructures().blockSet(setId); return null; }
/** {@inheritDoc} */ @Override public GridRestResponse call() throws Exception { final GridCacheProjection<Object, Object> cache = cache(g, cacheName).forSubjectId(clientId); // Need to apply both operation and response transformation remotely // as cache could be inaccessible on local node and // exception processing should be consistent with local execution. return op.apply(cache, ((GridKernal)g).context()).chain(resultWrapper(cache, key)).get(); } }
/** {@inheritDoc} */ @Override public Object call() throws Exception { GridServiceContextImpl svcCtx = ((GridKernal)grid).context().service().serviceContext(svcName); if (svcCtx == null) throw new GridServiceNotFoundException(svcName); GridServiceMethodReflectKey key = new GridServiceMethodReflectKey(mtdName, argTypes); Method mtd = svcCtx.method(key); if (mtd == null) throw new GridServiceMethodNotFoundException(svcName, mtdName, argTypes); return mtd.invoke(svcCtx.service(), args); }
@Nullable @Override public GridBiTuple<Long, Long> execute() throws GridException { GridGgfs ggfs = ((GridKernal)g).context().ggfs().ggfs(ggfsName); if (ggfs == null) return F.t(0L, 0L); GridGgfsMetrics metrics = ggfs.metrics(); long loc = metrics.localSpaceSize(); return F.t(loc, metrics.maxSpaceSize()); } });
@Nullable @Override public GridBiTuple<Long, Long> execute() throws GridException { GridGgfs ggfs = ((GridKernal)g).context().ggfs().ggfs(ggfsName); if (ggfs == null) return F.t(0L, 0L); GridGgfsMetrics metrics = ggfs.metrics(); long loc = metrics.localSpaceSize(); return F.t(loc, metrics.maxSpaceSize()); } });
/** {@inheritDoc} */ @Override public GridRestResponse call() throws Exception { GridCacheProjection<?, ?> prj = cache(g, cacheName).forSubjectId(clientId).flagsOn(flags); if (portable) prj = prj.keepPortable(); // Need to apply both operation and response transformation remotely // as cache could be inaccessible on local node and // exception processing should be consistent with local execution. return op.apply((GridCacheProjection<Object, Object>)prj, ((GridKernal)g).context()). chain(resultWrapper((GridCacheProjection<Object, Object>)prj, key)).get(); } }
final GridKernalContext ctx = ((GridKernal)grid).context();
/** Collect GGFS. */ private void ggfs(VisorDataCollectorJobResult res) { try { GridGgfsProcessorAdapter ggfsProc = ((GridKernal)g).context().ggfs(); for (GridGgfs ggfs : ggfsProc.ggfss()) { long start0 = U.currentTimeMillis(); try { Collection<GridIpcServerEndpoint> endPoints = ggfsProc.endpoints(ggfs.name()); if (endPoints != null) { for (GridIpcServerEndpoint ep : endPoints) if (ep.isManagement()) res.ggfsEndpoints.add(new VisorGgfsEndpoint(ggfs.name(), g.name(), ep.getHost(), ep.getPort())); } res.ggfss.add(VisorGgfs.from(ggfs)); } finally { if (debug) log(g.log(), "Collected GGFS: " + ggfs.name(), getClass(), start0); } } } catch(Throwable ggfssEx) { res.ggfssEx = ggfssEx; } }
GridGgfsProcessorAdapter ggfsProc = ((GridKernal)grid).context().ggfs();
/** * Handles increment and decrement commands. * * @param cache Cache. * @param key Key. * @param req Request. * @param decr Whether to decrement (increment otherwise). * @return Future of operation result. * @throws GridException In case of error. */ private static GridFuture<?> incrementOrDecrement(GridCacheProjection<Object, Object> cache, String key, GridRestCacheRequest req, final boolean decr) throws GridException { assert cache != null; assert key != null; assert req != null; Long init = req.initial(); Long delta = req.delta(); if (delta == null) throw new GridException(GridRestCommandHandlerAdapter.missingParameter("delta")); final GridCacheAtomicLong l = cache.cache().dataStructures().atomicLong(key, init != null ? init : 0, true); final Long d = delta; return ((GridKernal)cache.gridProjection().grid()).context().closure().callLocalSafe(new Callable<Object>() { @Override public Object call() throws Exception { return l.addAndGet(decr ? -d : d); } }, false); }