/** {@inheritDoc} */ @Override public Object result() { return convertResult(fut.result()); }
@Override public void apply(IgniteInternalFuture<MetadataUpdateResult> doneFut) { fut.onDone(doneFut.result(), doneFut.error()); } });
/** {@inheritDoc} */ @Override public boolean needForceKeys() { if (grp.rebalanceEnabled()) { IgniteInternalFuture<Boolean> rebalanceFut = rebalanceFuture(); if (rebalanceFut.isDone() && Boolean.TRUE.equals(rebalanceFut.result())) return false; } return true; }
onDone(fut.error()); else onDone(fut.result());
@Override public void apply(IgniteInternalFuture<Long> fut) { assert fut.error() != null || fut.result() != null : fut; try { clearLocalFuture((GridDhtTxQueryEnlistFuture)fut); GridNearTxQueryEnlistResponse res = fut.error() == null ? createResponse(fut) : null; localMini.onResult(res, fut.error()); } catch (IgniteCheckedException e) { localMini.onResult(null, e); } finally { CU.unwindEvicts(cctx); } } });
@Override public void apply(IgniteInternalFuture<Long> fut) { assert fut.error() != null || fut.result() != null : fut; try { clearLocalFuture((GridDhtTxAbstractEnlistFuture)fut); GridNearTxQueryResultsEnlistResponse res = fut.error() == null ? createResponse(fut) : null; if (checkResponse(nodeId, res, fut.error())) sendNextBatches(nodeId); } catch (IgniteCheckedException e) { checkResponse(nodeId, null, e); } finally { CU.unwindEvicts(cctx); } } });
@Override public void apply(IgniteInternalFuture<Collection<byte[]>> fut) { try { Collection<byte[]> grpKeys = fut.result(); if (F.size(grpKeys, F.alwaysTrue()) != keyCnt) res.onDone(false, fut.error()); IgniteInternalFuture<Boolean> dynStartCacheFut = after.apply(grpKeys); dynStartCacheFut.listen(new IgniteInClosure<IgniteInternalFuture<Boolean>>() { @Override public void apply(IgniteInternalFuture<Boolean> fut) { try { res.onDone(fut.get(), fut.error()); } catch (IgniteCheckedException e) { res.onDone(false, e); } } }); } catch (Exception e) { res.onDone(false, e); } } });
/** * @throws Exception If failed. */ @Test public void testHandleAsyncFromAndToNotSet() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); GridTestKernalContext ctx = newContext(cfg); GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx); GridRestLogRequest req = new GridRestLogRequest(); req.path(igniteHome + "/work/log/" + "test.log"); IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req); assertNull(resp.result().getError()); assertEquals(GridRestResponse.STATUS_SUCCESS, resp.result().getSuccessStatus()); assertNotNull(resp.result().getResponse()); }
/** * @throws Exception If failed. */ @Test public void testHandleAsyncPathNotSet() throws Exception { GridTestKernalContext ctx = newContext(); ctx.config().setIgniteHome(igniteHome); GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx); GridRestLogRequest req = new GridRestLogRequest(); req.to(5); req.from(2); IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req); assertNull(resp.result().getError()); assertEquals(GridRestResponse.STATUS_SUCCESS, resp.result().getSuccessStatus()); assertNotNull(resp.result().getResponse()); }
/** * @throws Exception If failed. */ @Test public void testHandleAsyncPathIsOutsideIgniteHome() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); GridTestKernalContext ctx = newContext(cfg); GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx); GridRestLogRequest req = new GridRestLogRequest(); req.to(5); req.from(2); req.path("/home/users/mytest.log"); IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req); assertEquals("Request parameter 'path' must contain a path to valid log file.", resp.result().getError()); assertEquals(GridRestResponse.STATUS_FAILED, resp.result().getSuccessStatus()); assertNull(resp.result().getResponse()); }
/** * @throws Exception If failed. */ @Test public void testHandleAsyncFromGreaterThanTo() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); GridTestKernalContext ctx = newContext(cfg); GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx); GridRestLogRequest req = new GridRestLogRequest(); req.to(5); req.from(7); req.path(igniteHome + "/work/log/" + "test.log"); IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req); assertEquals("Request parameter 'from' must be less than 'to'.", resp.result().getError()); assertEquals(GridRestResponse.STATUS_FAILED, resp.result().getSuccessStatus()); assertNull(resp.result().getResponse()); }
/** * @throws Exception If failed. */ @Test public void testHandleAsync() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); GridTestKernalContext ctx = newContext(cfg); GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx); GridRestLogRequest req = new GridRestLogRequest(); req.to(5); req.from(2); req.path(igniteHome + "/work/log/" + "test.log"); IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req); assertNull(resp.result().getError()); assertEquals(GridRestResponse.STATUS_SUCCESS, resp.result().getSuccessStatus()); assertNotNull(resp.result().getResponse()); }
/** * @throws Exception If failed. */ @Test public void testHandleAsyncForNonExistingLines() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); GridTestKernalContext ctx = newContext(cfg); GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx); GridRestLogRequest req = new GridRestLogRequest(); req.to(50); req.from(20); req.path(igniteHome + "/work/log/" + "test.log"); IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req); assertEquals("Request parameter 'from' and 'to' are for lines that do not exist in log file.", resp.result().getError()); assertEquals(GridRestResponse.STATUS_FAILED, resp.result().getSuccessStatus()); assertNull(resp.result().getResponse()); }
/** * @throws Exception If failed. */ @Test public void testHandleAsyncFromEqualTo() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteHome(igniteHome); GridTestKernalContext ctx = newContext(cfg); GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx); GridRestLogRequest req = new GridRestLogRequest(); req.to(5); req.from(5); req.path(igniteHome + "/work/log/" + "test.log"); IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req); assertEquals("Request parameter 'from' must be less than 'to'.", resp.result().getError()); assertEquals(GridRestResponse.STATUS_FAILED, resp.result().getSuccessStatus()); assertNull(resp.result().getResponse()); } }
/** {@inheritDoc} */ @Override public boolean rebalanceRequired(AffinityTopologyVersion rebTopVer, GridDhtPartitionsExchangeFuture exchFut) { if (ctx.kernalContext().clientNode() || rebTopVer.equals(AffinityTopologyVersion.NONE)) return false; // No-op. if (exchFut.resetLostPartitionFor(grp.cacheOrGroupName())) return true; if (exchFut.localJoinExchange()) return true; // Required, can have outdated updSeq partition counter if node reconnects. if (!grp.affinity().cachedVersions().contains(rebTopVer)) { assert rebTopVer.compareTo(grp.localStartVersion()) <= 0 : "Empty hisroty allowed only for newly started cache group [rebTopVer=" + rebTopVer + ", localStartTopVer=" + grp.localStartVersion() + ']'; return true; // Required, since no history info available. } final IgniteInternalFuture<Boolean> rebFut = rebalanceFuture(); if (rebFut.isDone() && !rebFut.result()) return true; // Required, previous rebalance cancelled. AffinityTopologyVersion lastAffChangeTopVer = ctx.exchange().lastAffinityChangedTopologyVersion(exchFut.topologyVersion()); return lastAffChangeTopVer.compareTo(rebTopVer) > 0; }
/** * @throws Exception If failed. */ @Test public void testNullCache() throws Exception { QueryCommandHandler cmdHnd = new QueryCommandHandler(grid().context()); Integer arg1 = 1000; Object[] arr = new Object[] {arg1, arg1}; RestQueryRequest req = new RestQueryRequest(); req.command(GridRestCommand.EXECUTE_SQL_QUERY); req.queryType(RestQueryRequest.QueryType.SCAN); req.typeName(Integer.class.getName()); req.pageSize(10); req.sqlQuery("salary+>+%3F+and+salary+<%3D+%3F"); req.arguments(arr); req.cacheName(null); IgniteInternalFuture<GridRestResponse> resp = cmdHnd.handleAsync(req); resp.get(); // If cache name is not set server uses name 'default'. assertEquals("Failed to find cache with name: default", resp.result().getError()); assertEquals(GridRestResponse.STATUS_FAILED, resp.result().getSuccessStatus()); assertNull(resp.result().getResponse()); }
onDone(fut.error()); else return new GridFinishedFuture<>(toEntryInfos(fut.result()));
oldFut.cancel(); else fut.listen(f -> oldFut.onDone(f.result()));
/** {@inheritDoc} */ @Override public boolean needForceKeys() { if (grp.rebalanceEnabled()) { IgniteInternalFuture<Boolean> rebalanceFut = rebalanceFuture(); if (rebalanceFut.isDone() && Boolean.TRUE.equals(rebalanceFut.result())) return false; } return true; }