@Override public String toString() { return Long.toString(jobId.getId()) + "-" + Long.toString(resultSetId.getId()); } }
@Test public void testNegativeCcId() { JobIdFactory factory = new JobIdFactory(CcId.valueOf(0xFFFF)); for (int i = 0; i < 1000; i++) { final JobId jobId = factory.create(); Assert.assertEquals((short) 0xFFFF, jobId.getCcId().shortValue()); Assert.assertEquals(i, jobId.getIdOnly()); Assert.assertTrue("JID not negative", jobId.getId() < 0); Assert.assertEquals(0xFFFF000000000000L + i, jobId.getId()); } }
public void updateMaxJobId(JobId jobId) { maxJobIds.computeIfAbsent(jobId.getCcId(), key -> new AtomicLong()) .getAndUpdate(currentMaxId -> Math.max(currentMaxId, jobId.getId())); }
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()); }
public TxnId getTxnJobId(JobId jobId) { return new TxnId(jobId.getId()); }
@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()); for (int i = 0; i < nBuffers; ++i) { ccb.getReadInterface().getEmptyBufferAcceptor().accept(ctx.allocateFrame()); } ByteBuffer writeBuffer = ByteBuffer.allocate(INITIAL_MESSAGE_SIZE); writeBuffer.putLong(jobId.getId()); writeBuffer.putLong(resultSetId.getId()); writeBuffer.putInt(partition); writeBuffer.flip(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sending partition request for JobId: " + jobId + " partition: " + partition + " on channel: " + ccb); } ccb.getWriteInterface().getFullBufferAcceptor().accept(writeBuffer); ccb.getWriteInterface().getFullBufferAcceptor().close(); }
@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 testParse() throws HyracksDataException { for (int ccId : Arrays.asList(0xFFFF, 0, (int) Short.MAX_VALUE)) { JobIdFactory factory = new JobIdFactory(CcId.valueOf(ccId)); for (int i = 0; i < 1000; i++) { final JobId jobId = factory.create(); Assert.assertEquals(jobId.getId(), JobId.parse(jobId.toString()).getId()); Assert.assertEquals(jobId, JobId.parse(jobId.toString())); Assert.assertFalse(jobId.toString(), jobId.toString().contains("-")); System.err.println(jobId.toString()); } } } }
public IHyracksTaskContext createTestContext(JobId jobId, int partition, boolean withMessaging) throws HyracksDataException { IHyracksTaskContext ctx = TestUtils.create(KB32, ExecutionTestUtil.integrationUtil.ncs[0].getIoManager()); if (withMessaging) { TaskUtil.put(HyracksConstants.KEY_MESSAGE, new VSizeFrame(ctx), ctx); } IHyracksJobletContext jobletCtx = Mockito.mock(IHyracksJobletContext.class); JobEventListenerFactory factory = new JobEventListenerFactory(new TxnId(jobId.getId()), true); Mockito.when(jobletCtx.getJobletEventListenerFactory()).thenReturn(factory); Mockito.when(jobletCtx.getServiceContext()).thenReturn(ExecutionTestUtil.integrationUtil.ncs[0].getContext()); Mockito.when(jobletCtx.getJobId()).thenReturn(jobId); ctx = Mockito.spy(ctx); Mockito.when(ctx.getJobletContext()).thenReturn(jobletCtx); Mockito.when(ctx.getIoManager()).thenReturn(ExecutionTestUtil.integrationUtil.ncs[0].getIoManager()); TaskAttemptId taskId = new TaskAttemptId(new TaskId(new ActivityId(new OperatorDescriptorId(0), 0), partition), 0); Mockito.when(ctx.getTaskAttemptId()).thenReturn(taskId); return ctx; }
@Override public IPushRuntime[] createPushRuntime(IHyracksTaskContext ctx) throws HyracksDataException { return new IPushRuntime[] { new CommitRuntime(ctx, new TxnId(ctx.getJobletContext().getJobId().getId()), getDatasetId(), primaryKeyFieldPermutation, true, ctx.getTaskAttemptId().getTaskId().getPartition(), true) }; } };