当前位置: 首页>>代码示例>>Java>>正文


Java TimeUnit.valueOf方法代码示例

本文整理汇总了Java中java.util.concurrent.TimeUnit.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java TimeUnit.valueOf方法的具体用法?Java TimeUnit.valueOf怎么用?Java TimeUnit.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.TimeUnit的用法示例。


在下文中一共展示了TimeUnit.valueOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseNotation

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
public NormalizedTimeUnit parseNotation(CharSequence notation, int value) {
    String candidate = notation.toString().toUpperCase();
    //jdk5 does not have days, hours or minutes, normalizing to millis
    if (candidate.equals("DAYS")) {
        return millis(value * 24 * 60 * 60 * 1000);
    } else if (candidate.equals("HOURS")) {
        return millis(value * 60 * 60 * 1000);
    } else if (candidate.equals("MINUTES")) {
        return millis(value * 60 * 1000);
    }
    try {
        return new NormalizedTimeUnit(value, TimeUnit.valueOf(candidate));
    } catch (Exception e) {
        throw new InvalidUserDataException("Unable to parse provided TimeUnit: " + notation, e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:TimeUnitsParser.java

示例2: toPrincipalRepository

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
@Override
public PrincipalAttributesRepository toPrincipalRepository(final ServiceData data) {
    final RegisteredServiceAttributeReleasePolicyEditBean attrRelease = data.getAttrRelease();
    final String attrType = attrRelease.getAttrOption();

    if (StringUtils.equalsIgnoreCase(attrType, RegisteredServiceAttributeReleasePolicyEditBean.Types.CACHED
            .toString())) {
        return new CachingPrincipalAttributesRepository(TimeUnit.valueOf(attrRelease.getCachedTimeUnit()
                .toUpperCase()), attrRelease.getCachedExpiration());
    } else if (StringUtils.equalsIgnoreCase(attrType, RegisteredServiceAttributeReleasePolicyEditBean.Types
            .DEFAULT.toString())) {
        return new DefaultPrincipalAttributesRepository();
    }

    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:DefaultPrincipalAttributesRepositoryMapper.java

示例3: DataStoreAccesor

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
public DataStoreAccesor ( final File basePath, final DataFilePool pool ) throws Exception
{
    this.basePath = basePath;
    this.pool = pool;

    if ( !basePath.isDirectory () )
    {
        throw new IllegalStateException ( String.format ( "'%s' is not a directory", basePath ) );
    }

    final Properties p = new Properties ();
    p.loadFromXML ( new FileInputStream ( new File ( basePath, "settings.xml" ) ) );

    this.time = Long.parseLong ( p.getProperty ( "time" ) );
    this.unit = TimeUnit.valueOf ( p.getProperty ( "unit" ) );
    this.count = Integer.parseInt ( p.getProperty ( "count" ) );
    this.quantizer = new Quantizer ( this.time, this.unit, this.count );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:DataStoreAccesor.java

示例4: makeTimestamp

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
private Calendar makeTimestamp ( final ConfigurationDataHelper cfg ) throws ParseException
{
    final Calendar c = Calendar.getInstance ();

    final String timeString = cfg.getString ( "timeString" );
    if ( timeString != null && !timeString.isEmpty () )
    {
        c.setTime ( new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss.SSS" ).parse ( timeString ) );
    }

    final long timeDiff = cfg.getLong ( "timeDiff.value", 0 );
    final TimeUnit timeDiffUnit = TimeUnit.valueOf ( cfg.getString ( "timeDiff.unit", TimeUnit.MILLISECONDS.toString () ) );

    c.add ( Calendar.MILLISECOND, (int)TimeUnit.MILLISECONDS.convert ( timeDiff, timeDiffUnit ) );

    return c;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:ConstantDataSource.java

示例5: valueOf

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
/**
 * Parses {@link Interval} from string.
 * @param string the string to parse.
 * @return the parsed {@link Interval}; null if cannot be parsed.
 */
public static Interval valueOf(final String string) {
  if (string == null) return null;
  String parts[] = string.split(":", 2);
  if (parts.length != 2) return null;
  String subparts[] = parts[0].split("-",2);
  long min, max;
  if (subparts.length == 1) {
    min = max = Long.valueOf(subparts[0]);
  } else if (subparts.length == 2) {
    min = Long.valueOf(subparts[0]);
    max = Long.valueOf(subparts[1]);
  } else {
    return null;
  }
  TimeUnit unit = TimeUnit.valueOf(parts[1]);
  return new Interval(min, max, unit);
}
 
开发者ID:braineering,项目名称:ares,代码行数:23,代码来源:Interval.java

示例6: valueOf

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
/**
 * Parses {@link Duration} from string.
 * @param string the string to parse.
 * @return the parsed {@link Duration}; null if cannot be parsed.
 */
public static Duration valueOf(String string) {
  if (string == null) return null;
  String parts[] = string.split(":", 2);
  if (parts.length != 2) return null;
  long amount = Long.valueOf(parts[0]);
  TimeUnit unit = TimeUnit.valueOf(parts[1]);
  return new Duration(amount, unit);
}
 
开发者ID:braineering,项目名称:ares,代码行数:14,代码来源:Duration.java

示例7: getDurationNanos

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
protected Long getDurationNanos(Properties properties, String propBase) {
    String durationString = StringUtils.emptyToNull(properties.getProperty(propBase));
    if (durationString == null) {
        return null;
    }
    long duration = Long.parseLong(durationString);
    String unitString = StringUtils.emptyToNull(properties.getProperty(propBase + ".unit"));
    TimeUnit timeUnit = TimeUnit.MILLISECONDS;
    if (unitString != null) {
        timeUnit = TimeUnit.valueOf(unitString);
    }
    return timeUnit.toNanos(duration);
}
 
开发者ID:hortonworks,项目名称:nifi-android-s2s,代码行数:14,代码来源:PropertiesSiteToSiteClientConfigFactory.java

示例8: setSchedulerDelayUnit

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
public void setSchedulerDelayUnit(final String schedulerDelayUnit) {
    try {
        this.schedulerDelayUnit = TimeUnit.valueOf(schedulerDelayUnit);
    } catch (final IllegalArgumentException e) {
        LOGGER.warn("Invalid schedulerDelayUnit value \"{}\"! The default value of {} will be used instead.",
                TimeUnit.SECONDS, e);
    }
}
 
开发者ID:cerner,项目名称:jwala,代码行数:9,代码来源:JGroupsReportingLifeCycleListener.java

示例9: rateUnits

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
default TimeUnit rateUnits() {
    String v = get(prefix() + ".rateUnits");
    return v == null ? TimeUnit.SECONDS : TimeUnit.valueOf(v.toUpperCase());
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:5,代码来源:GangliaConfig.java

示例10: durationUnits

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
default TimeUnit durationUnits() {
    String v = get(prefix() + ".durationUnits");
    return v == null ? TimeUnit.MILLISECONDS : TimeUnit.valueOf(v.toUpperCase());
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:5,代码来源:GangliaConfig.java

示例11: main

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
/**
 * The program main method.
 * @param args the command line arguments.
 */
public static void main(String[] args) throws Exception {

  // CONFIGURATION
  ParameterTool parameter = ParameterTool.fromArgs(args);
  final int port = Integer.valueOf(parameter.getRequired("port"));
  final Path outputPath = FileSystems.getDefault().getPath(parameter.get("output", PROGRAM_NAME + ".out"));
  final long windowSize = parameter.getLong("windowSize", 10);
  final TimeUnit windowUnit = TimeUnit.valueOf(parameter.get("windowUnit", "SECONDS"));
  final int parallelism = parameter.getInt("parallelism", 1);

  // ENVIRONMENT
  final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
  env.setStreamTimeCharacteristic(TimeCharacteristic.IngestionTime);

  // CONFIGURATION RESUME
  System.out.println("############################################################################");
  System.out.printf("%s\n", PROGRAM_NAME);
  System.out.println("----------------------------------------------------------------------------");
  System.out.printf("%s\n", PROGRAM_DESCRIPTION);
  System.out.println("****************************************************************************");
  System.out.println("Port: " + port);
  System.out.println("Output: " + outputPath);
  System.out.println("Window: " + windowSize + " " + windowUnit);
  System.out.println("Parallelism: " + parallelism);
  System.out.println("############################################################################");

  // TOPOLOGY
  DataStream<String> text = env.socketTextStream("localhost", port, "\n");

  DataStream<WordWithCount> windowCounts = text
      .flatMap(new WordTokenizer())
      .keyBy("word")
      .timeWindow(Time.of(windowSize, windowUnit))
      .reduce(new WordCountReducer())
      .setParallelism(parallelism);

  windowCounts.writeAsText(outputPath.toAbsolutePath().toString(), FileSystem.WriteMode.OVERWRITE);

  // EXECUTION
  env.execute(PROGRAM_NAME);
}
 
开发者ID:gmarciani,项目名称:flink-scaffolding,代码行数:46,代码来源:TopologyQuery1.java

示例12: main

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
/**
 * The program main method.
 * @param args the command line arguments.
 */
public static void main(String[] args) throws Exception {
  // CONFIGURATION
  ParameterTool parameter = ParameterTool.fromArgs(args);
  final int port = Integer.valueOf(parameter.getRequired("port"));
  final Path outputPath = FileSystems.getDefault().getPath(parameter.get("output", PROGRAM_NAME + ".out"));
  final long windowSize = parameter.getLong("windowSize", 10);
  final TimeUnit windowUnit = TimeUnit.valueOf(parameter.get("windowUnit", "SECONDS"));
  final int rankSize = parameter.getInt("rankSize", 3);
  final int parallelism = parameter.getInt("parallelism", 1);

  // ENVIRONMENT
  final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
  env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);

  // CONFIGURATION RESUME
  System.out.println("############################################################################");
  System.out.printf("%s\n", PROGRAM_NAME);
  System.out.println("----------------------------------------------------------------------------");
  System.out.printf("%s\n", PROGRAM_DESCRIPTION);
  System.out.println("****************************************************************************");
  System.out.println("Port: " + port);
  System.out.println("Output: " + outputPath);
  System.out.println("Window: " + windowSize + " " + windowUnit);
  System.out.println("Rank Size: " + rankSize);
  System.out.println("Parallelism: " + parallelism);
  System.out.println("############################################################################");

  // TOPOLOGY
  DataStream<TimedWord> timedWords = env.addSource(new StoppableTimedWordSocketSource("localhost", port))
      .assignTimestampsAndWatermarks(new EventTimestampExtractor());

  DataStream<WindowWordWithCount> windowCounts = timedWords
      .keyBy(new WordKeySelector())
      .timeWindow(Time.of(windowSize, windowUnit))
      .aggregate(new TimedWordCounterAggregator(), new TimedWordCounterWindowFunction())
      .setParallelism(parallelism);

  DataStream<WindowWordRanking> ranking = windowCounts.timeWindowAll(Time.of(windowSize, windowUnit))
      .apply(new WordRankerWindowFunction(rankSize));

  ranking.writeAsText(outputPath.toAbsolutePath().toString(), FileSystem.WriteMode.OVERWRITE);

  // EXECUTION
  env.execute(PROGRAM_NAME);
}
 
开发者ID:gmarciani,项目名称:flink-scaffolding,代码行数:50,代码来源:TopologyQuery2.java

示例13: main

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
/**
 * The program main method.
 * @param args the command line arguments.
 */
public static void main(String[] args) throws Exception {
  // CONFIGURATION
  ParameterTool parameter = ParameterTool.fromArgs(args);
  final String kafkaZookeeper = parameter.get("kafka.zookeeper", "localhost:2181");
  final String kafkaBootstrap = parameter.get("kafka.bootstrap", "localhost:9092");
  final String kafkaTopic = parameter.get("kafka.topic", "topic-query-3");
  final Path outputPath = FileSystems.getDefault().getPath(parameter.get("output", PROGRAM_NAME + ".out"));
  final String elasticsearch = parameter.get("elasticsearch", null);
  final long windowSize = parameter.getLong("windowSize", 10);
  final TimeUnit windowUnit = TimeUnit.valueOf(parameter.get("windowUnit", "SECONDS"));
  final int rankSize = parameter.getInt("rankSize", 3);
  final long tsEnd = parameter.getLong("tsEnd", 100000L);
  final Set<String> ignoredWords = Sets.newHashSet(parameter.get("ignoredWords", "")
      .trim().split(","));
  final int parallelism = parameter.getInt("parallelism", 1);

  // ENVIRONMENT
  final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
  env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
  env.setParallelism(parallelism);
  final KafkaProperties kafkaProps = new KafkaProperties(kafkaBootstrap, kafkaZookeeper);
  final ESProperties elasticsearchProps = ESProperties.fromPropString(elasticsearch);

  // CONFIGURATION RESUME
  System.out.println("############################################################################");
  System.out.printf("%s\n", PROGRAM_NAME);
  System.out.println("----------------------------------------------------------------------------");
  System.out.printf("%s\n", PROGRAM_DESCRIPTION);
  System.out.println("****************************************************************************");
  System.out.println("Kafka Zookeeper: " + kafkaZookeeper);
  System.out.println("Kafka Bootstrap: " + kafkaBootstrap);
  System.out.println("Kafka Topic: " + kafkaTopic);
  System.out.println("Output: " + outputPath);
  System.out.println("Elasticsearch: " + elasticsearch);
  System.out.println("Window: " + windowSize + " " + windowUnit);
  System.out.println("Rank Size: " + rankSize);
  System.out.println("Timestamp End: " + tsEnd);
  System.out.println("Ignored Words: " + ignoredWords);
  System.out.println("Parallelism: " + parallelism);
  System.out.println("############################################################################");

  // TOPOLOGY
  DataStream<TimedWord> timedWords = env.addSource(new StoppableTimedWordKafkaSource(kafkaTopic, kafkaProps, tsEnd));

  DataStream<TimedWord> fileterTimedWords = timedWords.filter(new TimedWordFilter(ignoredWords))
      .assignTimestampsAndWatermarks(new EventTimestampExtractor());

  DataStream<WindowWordWithCount> windowCounts = fileterTimedWords
      .keyBy(new WordKeySelector())
      .timeWindow(Time.of(windowSize, windowUnit))
      .aggregate(new TimedWordCounterAggregator(), new TimedWordCounterWindowFunction());

  DataStream<WindowWordRanking> ranking = windowCounts.timeWindowAll(Time.of(windowSize, windowUnit))
      .apply(new WordRankerWindowFunction(rankSize));

  ranking.writeAsText(outputPath.toAbsolutePath().toString(), FileSystem.WriteMode.OVERWRITE);

  if (elasticsearch != null) {
    ranking.addSink(new ESSink<>(elasticsearchProps,
        new MyESSinkFunction(elasticsearchProps.getIndexName(), elasticsearchProps.getTypeName()))
    );
  }

  // EXECUTION
  env.execute(PROGRAM_NAME);
}
 
开发者ID:gmarciani,项目名称:flink-scaffolding,代码行数:71,代码来源:TopologyQuery3.java

示例14: main

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
/**
 * The program main method.
 * @param args the command line arguments.
 */
public static void main(String[] args) throws Exception {

  // CONFIGURATION
  ParameterTool parameter = ParameterTool.fromArgs(args);
  final String kafkaZookeeper = parameter.get("kafka.zookeeper", "localhost:2181");
  final String kafkaBootstrap = parameter.get("kafka.bootstrap", "localhost:9092");
  final String kafkaTopic = parameter.get("kafka.topic", "socstream");
  final Path outputPath = FileSystems.getDefault().getPath(parameter.get("output", PROGRAM_NAME + ".out"));
  final String elasticsearch = parameter.get("elasticsearch", null);
  final Path metadataPath = FileSystems.getDefault().getPath(parameter.get("metadata", "./metadata.yml"));
  final long windowSize = parameter.getLong("windowSize", 70);
  final TimeUnit windowUnit = TimeUnit.valueOf(parameter.get("windowUnit", "MINUTES"));
  final long matchStart = parameter.getLong("match.start", 10753295594424116L);
  final long matchEnd = parameter.getLong("match.end", 14879639146403495L);
  final long matchIntervalStart = parameter.getLong("match.interval.start", 12557295594424116L);
  final long matchIntervalEnd = parameter.getLong("match.interval.end", 13086639146403495L);
  final int parallelism = parameter.getInt("parallelism", 1);
  final Match match = MatchService.fromYamlFile(metadataPath);
  final Set<Long> ignoredSensors = MatchService.collectIgnoredSensors(match);
  final Map<Long,Long> sid2Pid = MatchService.collectSid2Pid(match);

  // ENVIRONMENT
  final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
  env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
  final KafkaProperties kafkaProps = new KafkaProperties(kafkaBootstrap);
  final ESProperties elasticsearchProps = ESProperties.fromPropString(elasticsearch);

  // CONFIGURATION RESUME
  System.out.println("############################################################################");
  System.out.printf("%s\n", PROGRAM_NAME);
  System.out.println("----------------------------------------------------------------------------");
  System.out.printf("%s\n", PROGRAM_DESCRIPTION);
  System.out.println("****************************************************************************");
  System.out.println("Kafka Zookeeper: " + kafkaZookeeper);
  System.out.println("Kafka Bootstrap: " + kafkaBootstrap);
  System.out.println("Kafka Topic: " + kafkaTopic);
  System.out.println("Output: " + outputPath);
  System.out.println("Elasticsearch: " + elasticsearch);
  System.out.println("Metadata: " + metadataPath);
  System.out.println("Window: " + windowSize + " " + windowUnit);
  System.out.println("Match Start: " + matchStart);
  System.out.println("Match End: " + matchEnd);
  System.out.println("Match Interval Start: " + matchIntervalStart);
  System.out.println("Match Interval End: " + matchIntervalEnd);
  System.out.println("Ignored Sensors: " + ignoredSensors);
  System.out.println("Parallelism: " + parallelism);
  System.out.println("############################################################################");

  // TOPOLOGY
  DataStream<RichSensorEvent> sensorEvents = env.addSource(
      new RichSensorEventKafkaSource(kafkaTopic, kafkaProps, matchStart, matchEnd,
          matchIntervalStart, matchIntervalEnd, ignoredSensors, sid2Pid
      )
  ).assignTimestampsAndWatermarks(new RichSensorEventTimestampExtractor()).setParallelism(parallelism);

  DataStream<PlayerRunningStatistics> statistics = sensorEvents.keyBy(new RichSensorEventKeyer())
      .timeWindow(Time.of(windowSize, windowUnit))
      .aggregate(new PlayerRunningStatisticsCalculatorAggregator(), new PlayerRunningStatisticsCalculatorWindowFunction())
      .setParallelism(parallelism);

  statistics.writeAsText(outputPath.toAbsolutePath().toString(), FileSystem.WriteMode.OVERWRITE).setParallelism(1);

  if (elasticsearch != null) {
    statistics.addSink(new ESSink<>(elasticsearchProps,
        new PlayerRunningStatisticsESSinkFunction(elasticsearchProps.getIndexName(), elasticsearchProps.getTypeName()))
    ).setParallelism(1);
  }

  // EXECUTION
  env.execute(PROGRAM_NAME);
}
 
开发者ID:braineering,项目名称:socstream,代码行数:76,代码来源:TopologyQuery1.java

示例15: main

import java.util.concurrent.TimeUnit; //导入方法依赖的package包/类
/**
 * The program main method.
 * @param args the command line arguments.
 */
public static void main(String[] args) throws Exception {

  // CONFIGURATION
  ParameterTool parameter = ParameterTool.fromArgs(args);
  final String kafkaZookeeper = parameter.get("kafka.zookeeper", "localhost:2181");
  final String kafkaBootstrap = parameter.get("kafka.bootstrap", "localhost:9092");
  final String kafkaTopic = parameter.get("kafka.topic", "socstream");
  final Path outputPath = FileSystems.getDefault().getPath(parameter.get("output", PROGRAM_NAME + ".out"));
  final String elasticsearch = parameter.get("elasticsearch", null);
  final Path metadataPath = FileSystems.getDefault().getPath(parameter.get("metadata", "./metadata.yml"));
  final long windowSize = parameter.getLong("windowSize", 70);
  final TimeUnit windowUnit = TimeUnit.valueOf(parameter.get("windowUnit", "MINUTES"));
  final int rankSize = parameter.getInt("rankSize", 5);
  final long matchStart = parameter.getLong("match.start", 10753295594424116L);
  final long matchEnd = parameter.getLong("match.end", 14879639146403495L);
  final long matchIntervalStart = parameter.getLong("match.interval.start", 12557295594424116L);
  final long matchIntervalEnd = parameter.getLong("match.interval.end", 13086639146403495L);
  final int parallelism = parameter.getInt("parallelism", 1);

  final Match match = MatchService.fromYamlFile(metadataPath);
  final Set<Long> ignoredSensors = MatchService.collectIgnoredSensors(match);
  final Map<Long,Long> sid2Pid = MatchService.collectSid2Pid(match);

  // ENVIRONMENT
  final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
  env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
  final KafkaProperties kafkaProps = new KafkaProperties(kafkaBootstrap);
  final ESProperties elasticsearchProps = ESProperties.fromPropString(elasticsearch);

  // CONFIGURATION RESUME
  System.out.println("############################################################################");
  System.out.printf("%s\n", PROGRAM_NAME);
  System.out.println("----------------------------------------------------------------------------");
  System.out.printf("%s\n", PROGRAM_DESCRIPTION);
  System.out.println("****************************************************************************");
  System.out.println("Kafka Zookeeper: " + kafkaZookeeper);
  System.out.println("Kafka Bootstrap: " + kafkaBootstrap);
  System.out.println("Kafka Topic: " + kafkaTopic);
  System.out.println("Output: " + outputPath);
  System.out.println("Elasticsearch: " + elasticsearch);
  System.out.println("Metadata: " + metadataPath);
  System.out.println("Window: " + windowSize + " " + windowUnit);
  System.out.println("Rank Size: " + rankSize);
  System.out.println("Match Start: " + matchStart);
  System.out.println("Match End: " + matchEnd);
  System.out.println("Match Interval Start: " + matchIntervalStart);
  System.out.println("Match Interval End: " + matchIntervalEnd);
  System.out.println("Ignored Sensors: " + ignoredSensors);
  System.out.println("Parallelism: " + parallelism);
  System.out.println("############################################################################");

  // TOPOLOGY
  DataStream<SpeedSensorEvent> sensorEvents = env.addSource(
      new SpeedSensorEventKafkaSource(kafkaTopic, kafkaProps, matchStart, matchEnd,
          matchIntervalStart, matchIntervalEnd, ignoredSensors, sid2Pid
      )
  ).assignTimestampsAndWatermarks(new SpeedSensorEventTimestampExtractor()).setParallelism(parallelism);

  DataStream<PlayerSpeedStatistics> statistics = sensorEvents.keyBy(new SpeedSensorEventKeyer())
      .timeWindow(Time.of(windowSize, windowUnit))
      .aggregate(new PlayerSpeedStatisticsCalculatorAggregator(), new PlayerSpeedStatisticsCalculatorWindowFunction())
      .setParallelism(parallelism);

  DataStream<PlayersSpeedRanking> ranking = statistics.timeWindowAll(Time.of(windowSize, windowUnit))
      .apply(new GlobalRankerWindowFunction(rankSize));

  ranking.writeAsText(outputPath.toAbsolutePath().toString(), FileSystem.WriteMode.OVERWRITE).setParallelism(1);

  if (elasticsearch != null) {
    ranking.addSink(new ESSink<>(elasticsearchProps,
        new PlayerSpeedRankingESSinkFunction(elasticsearchProps.getIndexName(), elasticsearchProps.getTypeName()))
    ).setParallelism(1);
  }

  // EXECUTION
  env.execute(PROGRAM_NAME);
}
 
开发者ID:braineering,项目名称:socstream,代码行数:82,代码来源:TopologyQuery2.java


注:本文中的java.util.concurrent.TimeUnit.valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。