private void startReadFile() throws IOException { currentFileInfo = files.get(fileIndex); File snapshotFile = currentFileInfo.getPath().toFile(); currentFileSize = snapshotFile.length(); final int bufLength = getSnapshotChunkLength(currentFileSize); currentBuf = new byte[bufLength]; currentOffset = 0; chunkIndex = 0; in = new FileInputStream(snapshotFile); }
public SnapshotRequestIter(SnapshotInfo snapshot, String requestId) throws IOException { this.snapshot = snapshot; this.requestId = requestId; this.files = snapshot.getFiles(); if (files.size() > 0) { startReadFile(); } }
snapshotRequestObserver = getClient().installSnapshot(responseHandler); for (InstallSnapshotRequestProto request : new SnapshotRequestIter(snapshot, requestId)) { if (isAppenderRunning()) { snapshotRequestObserver.onNext(request);
private InstallSnapshotReplyProto installSnapshot(SnapshotInfo snapshot) throws InterruptedIOException { String requestId = UUID.randomUUID().toString(); InstallSnapshotReplyProto reply = null; try { for (InstallSnapshotRequestProto request : new SnapshotRequestIter(snapshot, requestId)) { follower.updateLastRpcSendTime(); reply = server.getServerRpc().installSnapshot(request); follower.updateLastRpcResponseTime(); if (!reply.getServerReply().getSuccess()) { return reply; } } } catch (InterruptedIOException iioe) { throw iioe; } catch (Exception ioe) { LOG.warn("{}: Failed to installSnapshot {}: {}", this, snapshot, ioe); handleException(ioe); return null; } if (reply != null) { follower.updateMatchIndex(snapshot.getTermIndex().getIndex()); follower.updateNextIndex(snapshot.getTermIndex().getIndex() + 1); LOG.info("{}: install snapshot-{} successfully on follower {}", server.getId(), snapshot.getTermIndex().getIndex(), follower.getPeer()); } return reply; }
private InstallSnapshotReplyProto installSnapshot(SnapshotInfo snapshot) throws InterruptedIOException { String requestId = UUID.randomUUID().toString(); InstallSnapshotReplyProto reply = null; try { for (InstallSnapshotRequestProto request : new SnapshotRequestIter(snapshot, requestId)) { follower.updateLastRpcSendTime(); reply = server.getServerRpc().installSnapshot(request); follower.updateLastRpcResponseTime(); if (!reply.getServerReply().getSuccess()) { return reply; } } } catch (InterruptedIOException iioe) { throw iioe; } catch (Exception ioe) { LOG.warn("{}: Failed to installSnapshot {}: {}", this, snapshot, ioe); handleException(ioe); return null; } if (reply != null) { follower.setSnapshotIndex(snapshot.getTermIndex().getIndex()); LOG.info("{}: install snapshot-{} successfully on follower {}", server.getId(), snapshot.getTermIndex().getIndex(), follower.getPeer()); } return reply; }
public SnapshotRequestIter(SnapshotInfo snapshot, String requestId) throws IOException { this.snapshot = snapshot; this.requestId = requestId; this.files = snapshot.getFiles(); if (files.size() > 0) { startReadFile(); } }
private void startReadFile() throws IOException { currentFileInfo = files.get(fileIndex); File snapshotFile = currentFileInfo.getPath().toFile(); currentFileSize = snapshotFile.length(); final int bufLength = getSnapshotChunkLength(currentFileSize); currentBuf = new byte[bufLength]; currentOffset = 0; chunkIndex = 0; in = new FileInputStream(snapshotFile); }