public static JobId parse(String str) throws HyracksDataException { Matcher m = jobIdPattern.matcher(str); if (m.matches()) { int ccId = Integer.parseInt(m.group(1)); if (ccId <= 0xffff && ccId >= 0) { long jobId = Long.parseLong(m.group(2)) | (long) ccId << CcIdPartitionedLongFactory.ID_BITS; return new JobId(jobId); } } throw HyracksDataException.create(ErrorCode.NOT_A_JOBID, str); }
@Override public String toString() { return Long.toString(jobId.getId()) + "-" + Long.toString(resultSetId.getId()); } }
@Override public String toString() { return "CancelJobRequest: " + jobId.toString(); }
public static JobId create(DataInput dis) throws IOException { JobId jobId = new JobId(); jobId.readFields(dis); return jobId; }
@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()); } } } }
@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 synchronized void jobsCompleted(CcId ccId) { failedJobsCache.asMap().keySet().removeIf(jobId -> jobId.getCcId().equals(ccId)); }
private void testOverflow(int id) throws IllegalAccessException { CcId ccId = CcId.valueOf(id); long expected = (long) id << 48; JobIdFactory factory = new JobIdFactory(ccId); AtomicLong theId = (AtomicLong) idField.get(factory); Assert.assertEquals(expected, theId.get()); theId.set((((long) 1 << 48) - 1) | expected); JobId jobId = factory.create(); Assert.assertEquals(ccId, jobId.getCcId()); Assert.assertEquals(CcIdPartitionedLongFactory.MAX_ID, jobId.getIdOnly()); jobId = factory.create(); Assert.assertEquals(ccId, jobId.getCcId()); Assert.assertEquals(0, jobId.getIdOnly()); }
public static void serialize(OutputStream out, Object object) throws Exception { NotifyJobletCleanupFunction fn = (NotifyJobletCleanupFunction) object; DataOutputStream dos = new DataOutputStream(out); fn.jobId.writeFields(dos); dos.writeUTF(fn.nodeId); } }
public static Object deserialize(ByteBuffer buffer, int length) throws Exception { ByteArrayInputStream bais = new ByteArrayInputStream(buffer.array(), buffer.position(), length); DataInputStream dis = new DataInputStream(bais); JobId jobId = JobId.create(dis); String nodeId = dis.readUTF(); return new NotifyJobletCleanupFunction(jobId, nodeId); }
private List<IPartition> unregisterPartitions(JobId jobId) { final List<IPartition> unregisteredPartitions = new ArrayList<>(); for (Iterator<Map.Entry<PartitionId, List<IPartition>>> i = availablePartitionMap.entrySet().iterator(); i .hasNext();) { Map.Entry<PartitionId, List<IPartition>> entry = i.next(); PartitionId pid = entry.getKey(); if (jobId.equals(pid.getJobId())) { unregisteredPartitions.addAll(entry.getValue()); i.remove(); } } return unregisteredPartitions; }
@Override public String toString() { return "JID:" + (id >>> CcIdPartitionedLongFactory.ID_BITS) + "." + getIdOnly(); }
JobId jobId = JobId.parse(arguments[0]);
@Override public void reportPartitionWriteCompletion(JobId jobId, ResultSetId rsId, int partition) throws HyracksException { try { LOGGER.trace("Reporting partition write completion: JobId: {}:ResultSetId: {}:partition: {}", jobId, rsId, partition); ncs.getClusterController(jobId.getCcId()).reportResultPartitionWriteCompletion(jobId, rsId, partition); } catch (Exception e) { throw HyracksException.create(e); } }
@Override public void writeFields(DataOutput output) throws IOException { cdId.writeFields(output); jobId.writeFields(output); output.writeInt(receiverIndex); output.writeInt(senderIndex); }
@Override public void readFields(DataInput input) throws IOException { cdId = ConnectorDescriptorId.create(input); jobId = JobId.create(input); receiverIndex = input.readInt(); senderIndex = input.readInt(); } }
private List<NetworkOutputChannel> removePendingRequests(JobId jobId, JobStatus status) { if (status != JobStatus.FAILURE) { return Collections.emptyList(); } final List<NetworkOutputChannel> pendingRequests = new ArrayList<>(); final Iterator<Map.Entry<PartitionId, NetworkOutputChannel>> requestsIterator = partitionRequests.entrySet().iterator(); while (requestsIterator.hasNext()) { final Map.Entry<PartitionId, NetworkOutputChannel> entry = requestsIterator.next(); final PartitionId partitionId = entry.getKey(); if (partitionId.getJobId().equals(jobId)) { pendingRequests.add(entry.getValue()); requestsIterator.remove(); } } return pendingRequests; } }
public ResultHandle(long jobId, long resultSetId) { this(new JobId(jobId), new ResultSetId(resultSetId)); }