public StreamMockEnvironment( Configuration jobConfig, Configuration taskConfig, ExecutionConfig executionConfig, long memorySize, MockInputSplitProvider inputSplitProvider, int bufferSize, TaskStateManager taskStateManager) { this( new JobID(), new ExecutionAttemptID(0L, 0L), jobConfig, taskConfig, executionConfig, memorySize, inputSplitProvider, bufferSize, taskStateManager); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } TaskExecutionStatus taskExecutionStatus = (TaskExecutionStatus) o; return executionAttemptID.equals(taskExecutionStatus.getExecutionAttemptID()); } }
@Override public String toString() { return partitionId.toString() + "@" + producerId.toString(); } }
@Override public int hashCode() { return partitionId.hashCode() ^ producerId.hashCode(); }
@Override public void readFrom(ByteBuf buffer) throws IOException { // TODO Directly deserialize fromNetty's buffer int length = buffer.readInt(); ByteBuffer serializedEvent = ByteBuffer.allocate(length); buffer.readBytes(serializedEvent); serializedEvent.flip(); event = (TaskEvent) EventSerializer.fromSerializedEvent(serializedEvent, getClass().getClassLoader()); partitionId = new ResultPartitionID(IntermediateResultPartitionID.fromByteBuf(buffer), ExecutionAttemptID.fromByteBuf(buffer)); receiverId = InputChannelID.fromByteBuf(buffer); } }
@Override ByteBuf write(ByteBufAllocator allocator) throws IOException { ByteBuf result = null; try { result = allocateBuffer(allocator, ID, 16 + 16 + 4 + 16); partitionId.getPartitionId().writeTo(result); partitionId.getProducerId().writeTo(result); result.writeInt(queueIndex); receiverId.writeTo(result); return result; } catch (Throwable t) { if (result != null) { result.release(); } throw new IOException(t); } }
@Override public boolean equals(Object obj) { if (obj instanceof TaskExecutionState) { TaskExecutionState other = (TaskExecutionState) obj; return other.jobID.equals(this.jobID) && other.executionId.equals(this.executionId) && other.executionState == this.executionState && (other.throwable == null) == (this.throwable == null); } else { return false; } }
@Override public String toString() { return partitionId.toString() + "@" + producerId.toString(); } }
@Override public int hashCode() { return job.hashCode() + taskExecutionId.hashCode() + (int) (checkpointId ^ (checkpointId >>> 32)); }
@Override public void readFrom(ByteBuf buffer) { partitionId = new ResultPartitionID(IntermediateResultPartitionID.fromByteBuf(buffer), ExecutionAttemptID.fromByteBuf(buffer)); queueIndex = buffer.readInt(); receiverId = InputChannelID.fromByteBuf(buffer); }
@Override ByteBuf write(ByteBufAllocator allocator) throws IOException { ByteBuf result = null; try { // TODO Directly serialize to Netty's buffer ByteBuffer serializedEvent = EventSerializer.toSerializedEvent(event); result = allocateBuffer(allocator, ID, 4 + serializedEvent.remaining() + 16 + 16 + 16); result.writeInt(serializedEvent.remaining()); result.writeBytes(serializedEvent); partitionId.getPartitionId().writeTo(result); partitionId.getProducerId().writeTo(result); receiverId.writeTo(result); return result; } catch (Throwable t) { if (result != null) { result.release(); } throw new IOException(t); } }
jobInformation, taskInformation, new ExecutionAttemptID(), new AllocationID(), 0,
@Override public boolean equals(Object obj) { if (obj instanceof TaskExecutionState) { TaskExecutionState other = (TaskExecutionState) obj; return other.jobID.equals(this.jobID) && other.executionId.equals(this.executionId) && other.executionState == this.executionState && (other.throwable == null) == (this.throwable == null); } else { return false; } }
@Override public String toString() { return partitionId.toString() + "@" + producerId.toString(); } }
@Override public int hashCode() { return partitionId.hashCode() ^ producerId.hashCode(); }
static AddCredit readFrom(ByteBuf buffer) { ResultPartitionID partitionId = new ResultPartitionID( IntermediateResultPartitionID.fromByteBuf(buffer), ExecutionAttemptID.fromByteBuf(buffer)); int credit = buffer.readInt(); InputChannelID receiverId = InputChannelID.fromByteBuf(buffer); return new AddCredit(partitionId, credit, receiverId); }
@Override ByteBuf write(ByteBufAllocator allocator) throws IOException { ByteBuf result = null; try { // TODO Directly serialize to Netty's buffer ByteBuffer serializedEvent = EventSerializer.toSerializedEvent(event); result = allocateBuffer(allocator, ID, 4 + serializedEvent.remaining() + 16 + 16 + 16); result.writeInt(serializedEvent.remaining()); result.writeBytes(serializedEvent); partitionId.getPartitionId().writeTo(result); partitionId.getProducerId().writeTo(result); receiverId.writeTo(result); return result; } catch (Throwable t) { if (result != null) { result.release(); } throw new IOException(t); } }
new ExecutionAttemptID(1L, 2L), mock(TaskLocalStateStoreImpl.class), null,
@Override public boolean equals(Object o) { if (this == o) { return true; } else if (o instanceof AbstractCheckpointMessage) { AbstractCheckpointMessage that = (AbstractCheckpointMessage) o; return this.job.equals(that.job) && this.taskExecutionId.equals(that.taskExecutionId) && this.checkpointId == that.checkpointId; } else { return false; } }
@Override public String toString() { return partitionId.toString() + "@" + producerId.toString(); } }