/** @see JournalProtocol#heartbeat */ @Override public HeartbeatResponseProto heartbeat(RpcController controller, HeartbeatRequestProto req) throws ServiceException { try { impl.heartbeat(convert(req.getReqInfo())); } catch (IOException e) { throw new ServiceException(e); } return HeartbeatResponseProto.getDefaultInstance(); }
getProxy().journal(createReqInfo(), segmentTxId, firstTxnId, numTxns, data); } catch (IOException e) {
@Override public Void call() throws IOException { getProxy().acceptRecovery(createReqInfo(), log, url); return null; } });
public void testStopSendingEditsWhenOutOfSync() throws Exception { Mockito.doThrow(new IOException("injected error")) .when(mockProxy).journal( Mockito.<RequestInfo>any(), Mockito.eq(1L), Mockito.eq(1L), GenericTestUtils.assertExceptionContains("injected", ee); Mockito.verify(mockProxy).journal( Mockito.<RequestInfo>any(), Mockito.eq(1L), Mockito.eq(1L), Mockito.verify(mockProxy, Mockito.never()).journal( Mockito.<RequestInfo>any(), Mockito.eq(1L), Mockito.eq(2L), Mockito.eq(1), Mockito.same(FAKE_DATA)); Mockito.verify(mockProxy).heartbeat( Mockito.<RequestInfo>any());
@Override public Void call() throws IOException { getProxy().doPreUpgrade(journalId); return null; } });
@Override public Void call() throws IOException { getProxy().doUpgrade(journalId, sInfo); return null; } });
@Override public Void call() throws IOException { getProxy().doRollback(journalId, nameServiceId); return null; } });
@Override public Void call() throws IOException { getProxy().doFinalize(journalId, nameServiceId); return null; } });
@Override public Void call() throws IOException { throwIfOutOfSync(); getProxy().finalizeLogSegment(createReqInfo(), startTxId, endTxId); return null; } });
@Override public Void call() throws IOException { getProxy().discardSegments(journalId, nameServiceId, startTxId); return null; } });
@Override public Boolean call() throws IOException { return getProxy().canRollBack(journalId, nameServiceId, storage, prevStorage, targetLayoutVersion); } });
@Override public DoPreUpgradeResponseProto doPreUpgrade(RpcController controller, DoPreUpgradeRequestProto request) throws ServiceException { try { impl.doPreUpgrade(convert(request.getJid())); return DoPreUpgradeResponseProto.getDefaultInstance(); } catch (IOException e) { throw new ServiceException(e); } }
@Override public DoUpgradeResponseProto doUpgrade(RpcController controller, DoUpgradeRequestProto request) throws ServiceException { StorageInfo si = PBHelper.convert(request.getSInfo(), NodeType.JOURNAL_NODE); try { impl.doUpgrade(convert(request.getJid()), si); return DoUpgradeResponseProto.getDefaultInstance(); } catch (IOException e) { throw new ServiceException(e); } }
@Override public DoRollbackResponseProto doRollback(RpcController controller, DoRollbackRequestProto request) throws ServiceException { try { impl.doRollback(convert(request.getJid()), request.getNameserviceId()); return DoRollbackResponseProto.getDefaultInstance(); } catch (IOException e) { throw new ServiceException(e); } }
@Override public DoFinalizeResponseProto doFinalize(RpcController controller, DoFinalizeRequestProto request) throws ServiceException { try { impl.doFinalize(convert(request.getJid()), request.hasNameServiceId() ? request.getNameServiceId() : null); return DoFinalizeResponseProto.getDefaultInstance(); } catch (IOException e) { throw new ServiceException(e); } }
@Override public FinalizeLogSegmentResponseProto finalizeLogSegment( RpcController controller, FinalizeLogSegmentRequestProto req) throws ServiceException { try { impl.finalizeLogSegment(convert(req.getReqInfo()), req.getStartTxId(), req.getEndTxId()); } catch (IOException e) { throw new ServiceException(e); } return FinalizeLogSegmentResponseProto.newBuilder().build(); }
@Override public DiscardSegmentsResponseProto discardSegments( RpcController controller, DiscardSegmentsRequestProto request) throws ServiceException { try { impl.discardSegments(convert(request.getJid()), request.hasNameServiceId() ? request.getNameServiceId() : null, request.getStartTxId()); return DiscardSegmentsResponseProto.getDefaultInstance(); } catch (IOException e) { throw new ServiceException(e); } }
@Override public CanRollBackResponseProto canRollBack(RpcController controller, CanRollBackRequestProto request) throws ServiceException { try { StorageInfo si = PBHelper.convert(request.getStorage(), NodeType.JOURNAL_NODE); Boolean result = impl.canRollBack(convert(request.getJid()), request.hasNameServiceId() ? request.getNameServiceId() : null, si, PBHelper.convert(request.getPrevStorage(), NodeType.JOURNAL_NODE), request.getTargetLayoutVersion()); return CanRollBackResponseProto.newBuilder() .setCanRollBack(result) .build(); } catch (IOException e) { throw new ServiceException(e); } }
/** @see JournalProtocol#journal */ @Override public JournalResponseProto journal(RpcController unused, JournalRequestProto req) throws ServiceException { try { impl.journal(convert(req.getReqInfo()), req.getSegmentTxnId(), req.getFirstTxnId(), req.getNumTxns(), req.getRecords().toByteArray()); } catch (IOException e) { throw new ServiceException(e); } return VOID_JOURNAL_RESPONSE; }
/** * When we've entered an out-of-sync state, it's still useful to periodically * send an empty RPC to the server, such that it has the up to date * committedTxId. This acts as a sanity check during recovery, and also allows * that node's metrics to be up-to-date about its lag. * * In the future, this method may also be used in order to check that the * current node is still the current writer, even if no edits are being * written. */ private void heartbeatIfNecessary() throws IOException { if (lastHeartbeatStopwatch.now(TimeUnit.MILLISECONDS) > HEARTBEAT_INTERVAL_MILLIS || !lastHeartbeatStopwatch.isRunning()) { try { getProxy().heartbeat(createReqInfo()); } finally { // Don't send heartbeats more often than the configured interval, // even if they fail. lastHeartbeatStopwatch.reset().start(); } } }