@Override public ConnectorDescriptorId createConnectorDescriptor(IConnectorDescriptor conn) { ConnectorDescriptorId cdId = new ConnectorDescriptorId(connectorIdCounter++); conn.setConnectorId(cdId); connMap.put(cdId, conn); return cdId; }
@Override public String toString() { StringBuilder buffer = new StringBuilder(); opMap.forEach((key, value) -> { buffer.append(key.getId()).append(" : ").append(value.toString()).append("\n"); List<IConnectorDescriptor> inputs = opInputMap.get(key); if (inputs != null && !inputs.isEmpty()) { buffer.append(" Inputs:\n"); for (IConnectorDescriptor c : inputs) { buffer.append(" ").append(c.getConnectorId().getId()).append(" : ").append(c.toString()) .append("\n"); } } List<IConnectorDescriptor> outputs = opOutputMap.get(key); if (outputs != null && !outputs.isEmpty()) { buffer.append(" Outputs:\n"); for (IConnectorDescriptor c : outputs) { buffer.append(" ").append(c.getConnectorId().getId()).append(" : ").append(c.toString()) .append("\n"); } } }); buffer.append("\n").append("Constraints:\n").append(userConstraints); return buffer.toString(); }
@Override public void readFields(DataInput input) throws IOException { cdId = ConnectorDescriptorId.create(input); jobId = JobId.create(input); receiverIndex = input.readInt(); senderIndex = input.readInt(); } }
public static ConnectorDescriptorId create(DataInput dis) throws IOException { ConnectorDescriptorId connectorDescriptorId = new ConnectorDescriptorId(); connectorDescriptorId.readFields(dis); return connectorDescriptorId; }
@Override public void writeFields(DataOutput output) throws IOException { cdId.writeFields(output); jobId.writeFields(output); output.writeInt(receiverIndex); output.writeInt(senderIndex); }
ObjectNode jInput = om.createObjectNode(); jInput.put("input-port", i); jInput.put("connector-id", inputs.get(i).getConnectorId().toString()); jInputs.add(jInput); ObjectNode jOutput = om.createObjectNode(); jOutput.put("output-port", i); jOutput.put("connector-id", outputs.get(i).getConnectorId().toString()); jOutputs.add(jOutput);
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((cdId == null) ? 0 : cdId.hashCode()); result = prime * result + ((jobId == null) ? 0 : jobId.hashCode()); result = prime * result + receiverIndex; result = prime * result + senderIndex; return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; PartitionId other = (PartitionId) obj; if (cdId == null) { if (other.cdId != null) return false; } else if (!cdId.equals(other.cdId)) return false; if (jobId == null) { if (other.jobId != null) return false; } else if (!jobId.equals(other.jobId)) return false; if (receiverIndex != other.receiverIndex) return false; if (senderIndex != other.senderIndex) return false; return true; }
entry.getKey().writeFields(dos); ConnectorPolicyFactory.INSTANCE.writeConnectorPolicy(entry.getValue(), dos);
ObjectNode pidObj = om.createObjectNode(); pidObj.put("job-id", pid.getJobId().toString()); pidObj.put("connector-id", pid.getConnectorDescriptorId().toString()); pidObj.put("sender-index", pid.getSenderIndex()); pidObj.put("receiver-index", pid.getReceiverIndex());
private static PartitionId readPartitionId(DataInputStream dis) throws IOException { long jobId = dis.readLong(); int cdid = dis.readInt(); int senderIndex = dis.readInt(); int receiverIndex = dis.readInt(); PartitionId pid = new PartitionId(new JobId(jobId), new ConnectorDescriptorId(cdid), senderIndex, receiverIndex); return pid; }
private static void writePartitionId(DataOutputStream dos, PartitionId pid) throws IOException { dos.writeLong(pid.getJobId().getId()); dos.writeInt(pid.getConnectorDescriptorId().getId()); dos.writeInt(pid.getSenderIndex()); dos.writeInt(pid.getReceiverIndex()); }
Map<ConnectorDescriptorId, IConnectorPolicy> connectorPolicies = new HashMap<>(); for (int i = 0; i < cpSize; i++) { ConnectorDescriptorId cid = ConnectorDescriptorId.create(dis); IConnectorPolicy policy = ConnectorPolicyFactory.INSTANCE.getConnectorPolicy(dis); connectorPolicies.put(cid, policy);
private static PartitionId readInitialMessage(ByteBuffer buffer) { JobId jobId = new JobId(buffer.getLong()); ConnectorDescriptorId cdid = new ConnectorDescriptorId(buffer.getInt()); int senderIndex = buffer.getInt(); int receiverIndex = buffer.getInt(); return new PartitionId(jobId, cdid, senderIndex, receiverIndex); }
@Override public void open(IHyracksCommonContext ctx) throws HyracksDataException { try { ccb = netManager.connect(remoteAddress); } catch (Exception e) { throw HyracksDataException.create(e); } ccb.getReadInterface().setFullBufferAcceptor(new ReadFullBufferAcceptor()); ccb.getWriteInterface().setEmptyBufferAcceptor(new WriteEmptyBufferAcceptor()); ccb.getReadInterface().setBufferFactory(new ReadBufferFactory(nBuffers, ctx), nBuffers, ctx.getInitialFrameSize()); ByteBuffer writeBuffer = ByteBuffer.allocate(INITIAL_MESSAGE_SIZE); writeBuffer.putLong(partitionId.getJobId().getId()); writeBuffer.putInt(partitionId.getConnectorDescriptorId().getId()); writeBuffer.putInt(partitionId.getSenderIndex()); writeBuffer.putInt(partitionId.getReceiverIndex()); writeBuffer.flip(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sending partition request: " + partitionId + " on channel: " + ccb); } ccb.getWriteInterface().getFullBufferAcceptor().accept(writeBuffer); ccb.getWriteInterface().getFullBufferAcceptor().close(); }
@Test public void failedJobPartitionRequestTest() throws Exception { final NodeControllerService nc1 = integrationUtil.ncs[0]; final NodeControllerService nc2 = integrationUtil.ncs[1]; final JobId failedJob = new JobId(-1); nc2.getPartitionManager().jobCompleted(failedJob, JobStatus.FAILURE); final NetworkAddress localNetworkAddress = nc2.getNetworkManager().getPublicNetworkAddress(); final InetSocketAddress nc2Address = new InetSocketAddress(localNetworkAddress.getAddress(), localNetworkAddress.getPort()); PartitionId id = new PartitionId(failedJob, new ConnectorDescriptorId(1), 0, 1); NetworkInputChannel inputChannel = new NetworkInputChannel(nc1.getNetworkManager(), nc2Address, id, 1); InputChannelFrameReader frameReader = new InputChannelFrameReader(inputChannel); inputChannel.registerMonitor(frameReader); AtomicBoolean failed = new AtomicBoolean(false); Thread reader = new Thread(() -> { try { failed.set(!frameReader.nextFrame(new FixedSizeFrame())); } catch (HyracksDataException e) { e.printStackTrace(); } }); reader.start(); final IHyracksCommonContext context = Mockito.mock(IHyracksCommonContext.class); Mockito.when(context.getInitialFrameSize()).thenReturn(2000); inputChannel.open(context); reader.join(5000); Assert.assertTrue(failed.get()); } }
JobId jobId = nc.newJobId(); final IHyracksTaskContext ctx = nc.createTestContext(jobId, 0, true); final ConnectorDescriptorId codId = new ConnectorDescriptorId(1); final PartitionId pid = new PartitionId(ctx.getJobletContext().getJobId(), codId, 1, 1); final ChannelControlBlock ccb = ncs.getNetworkManager()