Java Code Examples for org.apache.distributedlog.LogRecord#setControl()
The following examples show how to use
org.apache.distributedlog.LogRecord#setControl() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HeartbeatOp.java From distributedlog with Apache License 2.0 | 6 votes |
@Override protected Future<WriteResponse> executeOp(AsyncLogWriter writer, Sequencer sequencer, Object txnLock) { // write a control record if heartbeat is the first request of the recovered log segment. if (writeControlRecord) { long txnId; Future<DLSN> writeResult; synchronized (txnLock) { txnId = sequencer.nextId(); LogRecord hbRecord = new LogRecord(txnId, HEARTBEAT_DATA); hbRecord.setControl(); writeResult = newTFuture(writer.write(hbRecord)); } return writeResult.map(new AbstractFunction1<DLSN, WriteResponse>() { @Override public WriteResponse apply(DLSN value) { return ResponseUtils.writeSuccess().setDlsn(value.serialize(dlsnVersion)); } }); } else { return Future.value(ResponseUtils.writeSuccess()); } }
Example 2
Source File: TestBKLogSegmentEntryReader.java From distributedlog with Apache License 2.0 | 6 votes |
void generateCompletedLogSegments(DistributedLogManager dlm, DistributedLogConfiguration conf, long numCompletedSegments, long segmentSize) throws Exception { long txid = 1L; for (long i = 0; i < numCompletedSegments; i++) { AsyncLogWriter writer = Utils.ioResult(dlm.openAsyncLogWriter()); for (long j = 1; j <= segmentSize; j++) { Utils.ioResult(writer.write(DLMTestUtil.getLogRecordInstance(txid++))); LogRecord ctrlRecord = DLMTestUtil.getLogRecordInstance(txid); ctrlRecord.setControl(); Utils.ioResult(writer.write(ctrlRecord)); } Utils.close(writer); } }
Example 3
Source File: ClusterStateOpLog.java From Elasticsearch with Apache License 2.0 | 5 votes |
private void writeControlRecord(long version) throws IOException { try { LogRecord logRecord = new LogRecord(version, new byte[1]); logRecord.setControl(); Future<DLSN> result = logWriter.write(logRecord); FutureUtils.result(result); return; } catch (TransactionIdOutOfOrderException e) { throw e; } }
Example 4
Source File: TestBKLogSegmentEntryReader.java From distributedlog with Apache License 2.0 | 5 votes |
AsyncLogWriter createInprogressLogSegment(DistributedLogManager dlm, DistributedLogConfiguration conf, long segmentSize) throws Exception { AsyncLogWriter writer = Utils.ioResult(dlm.openAsyncLogWriter()); for (long i = 1L; i <= segmentSize; i++) { Utils.ioResult(writer.write(DLMTestUtil.getLogRecordInstance(i))); LogRecord ctrlRecord = DLMTestUtil.getLogRecordInstance(i); ctrlRecord.setControl(); Utils.ioResult(writer.write(ctrlRecord)); } return writer; }