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

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

本文整理了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

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

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

  1. @Override
  2. public String toString() {
  3. return "CarCount{" +
  4. "location='" + location + '\'' +
  5. ", time=" + toLocalDateTime(time) +
  6. ", count=" + count +
  7. '}';
  8. }
  9. }

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

  1. @Override
  2. public boolean complete() {
  3. return uncheckCall(this::tryComplete);
  4. }

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

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

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

  1. public SenderTasklet(InboundEdgeStream inboundEdgeStream, NodeEngine nodeEngine, Address destinationAddress,
  2. long executionId, int destinationVertexId, int packetSizeLimit) {
  3. this.inboundEdgeStream = inboundEdgeStream;
  4. this.packetSizeLimit = packetSizeLimit;
  5. this.connection = getMemberConnection(nodeEngine, destinationAddress);
  6. this.outputBuffer = createObjectDataOutput(nodeEngine);
  7. uncheckRun(() -> outputBuffer.write(createStreamPacketHeader(
  8. nodeEngine, executionId, destinationVertexId, inboundEdgeStream.ordinal())));
  9. bufPosPastHeader = outputBuffer.position();
  10. }

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

  1. private void broadcastFlowControlPacket() {
  2. try {
  3. getRemoteMembers(nodeEngine).forEach(member -> uncheckRun(() -> {
  4. final byte[] packetBuf = createFlowControlPacket(member);
  5. if (packetBuf.length == 0) {
  6. return;
  7. }
  8. Connection conn = getMemberConnection(nodeEngine, member);
  9. if (conn != null) {
  10. conn.write(new Packet(packetBuf)
  11. .setPacketType(Packet.Type.JET)
  12. .raiseFlags(FLAG_URGENT | FLAG_JET_FLOW_CONTROL));
  13. }
  14. }));
  15. } catch (Throwable t) {
  16. logger.severe("Flow-control packet broadcast failed", t);
  17. }
  18. }

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

  1. private byte[] createFlowControlPacket(Address member) throws IOException {
  2. try (BufferObjectDataOutput out = createObjectDataOutput(nodeEngine)) {
  3. final boolean[] hasData = {false};
  4. Map<Long, ExecutionContext> executionContexts = jobExecutionService.getExecutionContextsFor(member);
  5. out.writeInt(executionContexts.size());
  6. executionContexts.forEach((execId, exeCtx) -> uncheckRun(() -> {
  7. out.writeLong(execId);
  8. out.writeInt(exeCtx.receiverMap().values().stream().mapToInt(Map::size).sum());
  9. exeCtx.receiverMap().forEach((vertexId, ordinalToSenderToTasklet) ->
  10. ordinalToSenderToTasklet.forEach((ordinal, senderToTasklet) -> uncheckRun(() -> {
  11. out.writeInt(vertexId);
  12. out.writeInt(ordinal);
  13. out.writeInt(senderToTasklet.get(member).updateAndGetSendSeqLimitCompressed());
  14. hasData[0] = true;
  15. })));
  16. }));
  17. return hasData[0] ? out.toByteArray() : EMPTY_BYTES;
  18. }
  19. }

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

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

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

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

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

  1. @Override
  2. public void init(@Nonnull Context context) {
  3. if (clientXml != null) {
  4. instance = client = newHazelcastClient(asClientConfig(clientXml));
  5. } else {
  6. instance = context.jetInstance().getHazelcastInstance();
  7. }
  8. }

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

  1. @Override
  2. protected void restoreFromSnapshot(@Nonnull Object key, @Nonnull Object value) {
  3. @SuppressWarnings("unchecked")
  4. int partitionId = ((BroadcastKey<Integer>) key).key();
  5. int partitionIndex = arrayIndexOf(partitionId, partitionIds);
  6. long offset = ((long[]) value)[0];
  7. long wm = ((long[]) value)[1];
  8. if (partitionIndex >= 0) {
  9. readOffsets[partitionIndex] = offset;
  10. emitOffsets[partitionIndex] = offset;
  11. // Always use partition index of 0, treating all the partitions the
  12. // same for coalescing purposes.
  13. eventTimeMapper.restoreWatermark(0, wm);
  14. }
  15. }

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

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

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

  1. @Override
  2. public String toString() {
  3. return "TrendKey{" +
  4. "location='" + location + '\'' +
  5. ", time=" + toLocalDateTime(time) +
  6. '}';
  7. }
  8. }

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

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

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

  1. @Override
  2. public void init(@Nonnull Context context) {
  3. HazelcastInstance instance = context.jetInstance().getHazelcastInstance();
  4. if (clientXml != null) {
  5. client = newHazelcastClient(asClientConfig(clientXml));
  6. instance = client;
  7. }
  8. eventJournalReader = eventJournalReaderSupplier.apply(instance);
  9. }

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

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

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

  1. @Override
  2. public String toString() {
  3. return "Prediction{" +
  4. "location='" + location + '\'' +
  5. ", time=" + toLocalDateTime(time) + " (" + time + ")" +
  6. ", predictedCounts=" + Arrays.toString(predictedCounts) +
  7. '}';
  8. }
  9. }

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

  1. @Override
  2. public boolean complete() {
  3. if (traverser == null) {
  4. resultSet = uncheckCall(() -> resultSetFn.createResultSet(connection, parallelism, index));
  5. traverser = ((Traverser<ResultSet>) () -> uncheckCall(() -> resultSet.next() ? resultSet : null))
  6. .map(mapOutputFn);
  7. }
  8. return emitFromTraverser(traverser);
  9. }

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

  1. @Override
  2. public void init(@Nonnull Context context) {
  3. HazelcastInstance client = newHazelcastClient(asClientConfig(clientXml));
  4. try {
  5. HazelcastClientProxy clientProxy = (HazelcastClientProxy) client;
  6. remotePartitionCount = clientProxy.client.getClientPartitionService().getPartitionCount();
  7. } finally {
  8. client.shutdown();
  9. }
  10. }

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

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

相关文章