Java Code Examples for org.apache.flink.runtime.io.network.api.CheckpointBarrier#getCheckpointOptions()
The following examples show how to use
org.apache.flink.runtime.io.network.api.CheckpointBarrier#getCheckpointOptions() .
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: EventSerializer.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static ByteBuffer serializeCheckpointBarrier(CheckpointBarrier barrier) throws IOException { final CheckpointOptions checkpointOptions = barrier.getCheckpointOptions(); final CheckpointType checkpointType = checkpointOptions.getCheckpointType(); final byte[] locationBytes = checkpointOptions.getTargetLocation().isDefaultReference() ? null : checkpointOptions.getTargetLocation().getReferenceBytes(); final ByteBuffer buf = ByteBuffer.allocate(28 + (locationBytes == null ? 0 : locationBytes.length)); // we do not use checkpointType.ordinal() here to make the serialization robust // against changes in the enum (such as changes in the order of the values) final int typeInt; if (checkpointType == CheckpointType.CHECKPOINT) { typeInt = CHECKPOINT_TYPE_CHECKPOINT; } else if (checkpointType == CheckpointType.SAVEPOINT) { typeInt = CHECKPOINT_TYPE_SAVEPOINT; } else { throw new IOException("Unknown checkpoint type: " + checkpointType); } buf.putInt(CHECKPOINT_BARRIER_EVENT); buf.putLong(barrier.getId()); buf.putLong(barrier.getTimestamp()); buf.putInt(typeInt); if (locationBytes == null) { buf.putInt(-1); } else { buf.putInt(locationBytes.length); buf.put(locationBytes); } buf.flip(); return buf; }
Example 2
Source File: EventSerializer.java From flink with Apache License 2.0 | 5 votes |
private static ByteBuffer serializeCheckpointBarrier(CheckpointBarrier barrier) throws IOException { final CheckpointOptions checkpointOptions = barrier.getCheckpointOptions(); final CheckpointType checkpointType = checkpointOptions.getCheckpointType(); final byte[] locationBytes = checkpointOptions.getTargetLocation().isDefaultReference() ? null : checkpointOptions.getTargetLocation().getReferenceBytes(); final ByteBuffer buf = ByteBuffer.allocate(28 + (locationBytes == null ? 0 : locationBytes.length)); // we do not use checkpointType.ordinal() here to make the serialization robust // against changes in the enum (such as changes in the order of the values) final int typeInt; if (checkpointType == CheckpointType.CHECKPOINT) { typeInt = CHECKPOINT_TYPE_CHECKPOINT; } else if (checkpointType == CheckpointType.SAVEPOINT) { typeInt = CHECKPOINT_TYPE_SAVEPOINT; } else if (checkpointType == CheckpointType.SYNC_SAVEPOINT) { typeInt = CHECKPOINT_TYPE_SYNC_SAVEPOINT; } else { throw new IOException("Unknown checkpoint type: " + checkpointType); } buf.putInt(CHECKPOINT_BARRIER_EVENT); buf.putLong(barrier.getId()); buf.putLong(barrier.getTimestamp()); buf.putInt(typeInt); if (locationBytes == null) { buf.putInt(-1); } else { buf.putInt(locationBytes.length); buf.put(locationBytes); } buf.flip(); return buf; }
Example 3
Source File: EventSerializer.java From flink with Apache License 2.0 | 5 votes |
private static ByteBuffer serializeCheckpointBarrier(CheckpointBarrier barrier) throws IOException { final CheckpointOptions checkpointOptions = barrier.getCheckpointOptions(); final CheckpointType checkpointType = checkpointOptions.getCheckpointType(); final byte[] locationBytes = checkpointOptions.getTargetLocation().isDefaultReference() ? null : checkpointOptions.getTargetLocation().getReferenceBytes(); final ByteBuffer buf = ByteBuffer.allocate(30 + (locationBytes == null ? 0 : locationBytes.length)); // we do not use checkpointType.ordinal() here to make the serialization robust // against changes in the enum (such as changes in the order of the values) final int typeInt; if (checkpointType == CheckpointType.CHECKPOINT) { typeInt = CHECKPOINT_TYPE_CHECKPOINT; } else if (checkpointType == CheckpointType.SAVEPOINT) { typeInt = CHECKPOINT_TYPE_SAVEPOINT; } else if (checkpointType == CheckpointType.SYNC_SAVEPOINT) { typeInt = CHECKPOINT_TYPE_SYNC_SAVEPOINT; } else { throw new IOException("Unknown checkpoint type: " + checkpointType); } buf.putInt(CHECKPOINT_BARRIER_EVENT); buf.putLong(barrier.getId()); buf.putLong(barrier.getTimestamp()); buf.putInt(typeInt); if (locationBytes == null) { buf.putInt(-1); } else { buf.putInt(locationBytes.length); buf.put(locationBytes); } buf.put((byte) (checkpointOptions.isExactlyOnceMode() ? 1 : 0)); buf.put((byte) (checkpointOptions.isUnalignedCheckpoint() ? 1 : 0)); buf.flip(); return buf; }