com.hazelcast.jet.impl.util.Util类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(461)

本文整理了Java中com.hazelcast.jet.impl.util.Util类的一些代码示例,展示了Util类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util类的具体详情如下:
包路径:com.hazelcast.jet.impl.util.Util
类名称:Util

Util介绍

暂无

代码示例

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

private static void waitForComplete(Job job) {
    while (job.getStatus() != JobStatus.COMPLETED) {
      uncheckRun(() -> SECONDS.sleep(1));
    }
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet-demos

@Override
  public String toString() {
    return "CarCount{" +
        "location='" + location + '\'' +
        ", time=" + toLocalDateTime(time) +
        ", count=" + count +
        '}';
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public boolean complete() {
  return uncheckCall(this::tryComplete);
}

代码示例来源:origin: hazelcast/hazelcast-jet

/**
 * Returns the lowest frame timestamp greater than the given timestamp. If
 * there is no such {@code long} value, returns {@code Long.MAX_VALUE}.
 */
public long higherFrameTs(long timestamp) {
  long tsPlusFrame = timestamp + frameSize;
  return sumHadOverflow(timestamp, frameSize, tsPlusFrame)
      ? addClamped(floorFrameTs(timestamp), frameSize)
      : floorFrameTs(tsPlusFrame);
}

代码示例来源:origin: hazelcast/hazelcast-jet

public SenderTasklet(InboundEdgeStream inboundEdgeStream, NodeEngine nodeEngine, Address destinationAddress,
           long executionId, int destinationVertexId, int packetSizeLimit) {
  this.inboundEdgeStream = inboundEdgeStream;
  this.packetSizeLimit = packetSizeLimit;
  this.connection = getMemberConnection(nodeEngine, destinationAddress);
  this.outputBuffer = createObjectDataOutput(nodeEngine);
  uncheckRun(() -> outputBuffer.write(createStreamPacketHeader(
      nodeEngine, executionId, destinationVertexId, inboundEdgeStream.ordinal())));
  bufPosPastHeader = outputBuffer.position();
}

代码示例来源:origin: hazelcast/hazelcast-jet

private void broadcastFlowControlPacket() {
  try {
    getRemoteMembers(nodeEngine).forEach(member -> uncheckRun(() -> {
      final byte[] packetBuf = createFlowControlPacket(member);
      if (packetBuf.length == 0) {
        return;
      }
      Connection conn = getMemberConnection(nodeEngine, member);
      if (conn != null) {
        conn.write(new Packet(packetBuf)
            .setPacketType(Packet.Type.JET)
            .raiseFlags(FLAG_URGENT | FLAG_JET_FLOW_CONTROL));
      }
    }));
  } catch (Throwable t) {
    logger.severe("Flow-control packet broadcast failed", t);
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

private byte[] createFlowControlPacket(Address member) throws IOException {
  try (BufferObjectDataOutput out = createObjectDataOutput(nodeEngine)) {
    final boolean[] hasData = {false};
    Map<Long, ExecutionContext> executionContexts = jobExecutionService.getExecutionContextsFor(member);
    out.writeInt(executionContexts.size());
    executionContexts.forEach((execId, exeCtx) -> uncheckRun(() -> {
      out.writeLong(execId);
      out.writeInt(exeCtx.receiverMap().values().stream().mapToInt(Map::size).sum());
      exeCtx.receiverMap().forEach((vertexId, ordinalToSenderToTasklet) ->
          ordinalToSenderToTasklet.forEach((ordinal, senderToTasklet) -> uncheckRun(() -> {
            out.writeInt(vertexId);
            out.writeInt(ordinal);
            out.writeInt(senderToTasklet.get(member).updateAndGetSendSeqLimitCompressed());
            hasData[0] = true;
          })));
    }));
    return hasData[0] ? out.toByteArray() : EMPTY_BYTES;
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public void init(@Nonnull Context context) {
  client = newHazelcastClient(asClientConfig(clientXml));
  partitionToIterator = iteratorSupplier.apply(client);
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public final boolean offer(@Nonnull int[] ordinals, @Nonnull Object item) {
  assert snapshotEdge == null || Util.arrayIndexOf(snapshotEdge[0], ordinals) < 0
      : "Ordinal " + snapshotEdge[0] + " is out of range";
  return offerInternal(ordinals, item);
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public void init(@Nonnull Context context) {
  if (clientXml != null) {
    instance = client = newHazelcastClient(asClientConfig(clientXml));
  } else {
    instance = context.jetInstance().getHazelcastInstance();
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
protected void restoreFromSnapshot(@Nonnull Object key, @Nonnull Object value) {
  @SuppressWarnings("unchecked")
  int partitionId = ((BroadcastKey<Integer>) key).key();
  int partitionIndex = arrayIndexOf(partitionId, partitionIds);
  long offset = ((long[]) value)[0];
  long wm = ((long[]) value)[1];
  if (partitionIndex >= 0) {
    readOffsets[partitionIndex] = offset;
    emitOffsets[partitionIndex] = offset;
    // Always use partition index of 0, treating all the partitions the
    // same for coalescing purposes.
    eventTimeMapper.restoreWatermark(0, wm);
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

private static void waitForComplete(Job job) {
    while (job.getStatus() != JobStatus.COMPLETED) {
      uncheckRun(() -> SECONDS.sleep(1));
    }
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet-demos

@Override
  public String toString() {
    return "TrendKey{" +
        "location='" + location + '\'' +
        ", time=" + toLocalDateTime(time) +
        '}';
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public AttributeList getAttributes(String[] attributes) {
  return Arrays.stream(attributes)
         .filter(metrics::containsKey)
         .map(a -> uncheckCall(() -> new Attribute(a, getAttribute(a))))
         .collect(toCollection(AttributeList::new));
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public void init(@Nonnull Context context) {
  HazelcastInstance instance = context.jetInstance().getHazelcastInstance();
  if (clientXml != null) {
    client = newHazelcastClient(asClientConfig(clientXml));
    instance = client;
  }
  eventJournalReader = eventJournalReaderSupplier.apply(instance);
}

代码示例来源:origin: hazelcast/hazelcast-jet

private void submitBlockingTasklets(ExecutionTracker executionTracker, ClassLoader jobClassLoader,
                  List<Tasklet> tasklets) {
  CountDownLatch startedLatch = new CountDownLatch(tasklets.size());
  executionTracker.blockingFutures = tasklets
      .stream()
      .map(t -> new BlockingWorker(new TaskletTracker(t, executionTracker, jobClassLoader), startedLatch))
      .map(blockingTaskletExecutor::submit)
      .collect(toList());
  // do not return from this method until all workers have started. Otherwise
  // on cancellation there is a race where the executor might not have started
  // the worker yet. This would results in taskletDone() never being called for
  // a worker.
  uncheckRun(startedLatch::await);
}

代码示例来源:origin: hazelcast/hazelcast-jet-demos

@Override
  public String toString() {
    return "Prediction{" +
        "location='" + location + '\'' +
        ", time=" + toLocalDateTime(time) + " (" + time + ")" +
        ", predictedCounts=" + Arrays.toString(predictedCounts) +
        '}';
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public boolean complete() {
  if (traverser == null) {
    resultSet = uncheckCall(() -> resultSetFn.createResultSet(connection, parallelism, index));
    traverser = ((Traverser<ResultSet>) () -> uncheckCall(() -> resultSet.next() ? resultSet : null))
        .map(mapOutputFn);
  }
  return emitFromTraverser(traverser);
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public void init(@Nonnull Context context) {
  HazelcastInstance client = newHazelcastClient(asClientConfig(clientXml));
  try {
    HazelcastClientProxy clientProxy = (HazelcastClientProxy) client;
    remotePartitionCount = clientProxy.client.getClientPartitionService().getPartitionCount();
  } finally {
    client.shutdown();
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet-code-samples

private void createAvroFile() throws IOException {
  Path inputPath = new Path(INPUT_PATH);
  FileSystem fs = FileSystem.get(new Configuration());
  fs.delete(inputPath, true);
  DataFileWriter<User> fileWriter = new DataFileWriter<>(new GenericDatumWriter<User>(User.SCHEMA));
  fileWriter.create(User.SCHEMA, fs.create(new Path(inputPath, "file.avro")));
  IntStream.range(0, 100)
       .mapToObj(i -> new User("name" + i, "pass" + i, i, i % 2 == 0))
       .forEach(user -> Util.uncheckRun(() -> fileWriter.append(user)));
  fileWriter.close();
  fs.close();
}

相关文章