gpt4 book ai didi

com.bazaarvoice.emodb.common.zookeeper.store.ZkTimestampSerializer类的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 17:27:31 25 4
gpt4 key购买 nike

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

ZkTimestampSerializer介绍

[英]Formats a timestamp in ZooKeeper as a human-readable ISO-8601 string for transparency, easy debugging.
[中]将ZooKeeper中的时间戳格式化为人类可读的ISO-8601字符串,以便透明、易于调试。

代码示例

代码示例来源:origin: bazaarvoice/emodb

/** Provides a ZooKeeper-based IP black list. */
  @Provides @Singleton @BlackListIpValueStore
  MapStore<Long> provideBlackListIps(@Global CuratorFramework curator, LifeCycleRegistry lifeCycle) {
    CuratorFramework webCurator = withComponentNamespace(curator, "web");
    return lifeCycle.manage(new ZkMapStore<>(webCurator, "/blacklist", new ZkTimestampSerializer()));
  }
}

代码示例来源:origin: bazaarvoice/emodb

@Override
  public AdHocThrottle fromString(String string) {
    if (string == null) {
      return null;
    }
    try {
      int comma = string.indexOf(",");
      int limit = Integer.parseInt(string.substring(0, comma));
      Instant expiration = Instant.ofEpochMilli(TIMESTAMP_SERIALIZER.fromString(string.substring(comma + 1)));
      return AdHocThrottle.create(limit, expiration);
    } catch (IllegalArgumentException e) {
      throw new IllegalArgumentException("Throttle string must be of the form \"limit,expiration date\"");
    }
  }
}

代码示例来源:origin: bazaarvoice/emodb

@Override
public String toString(AdHocThrottle throttle) {
  return String.format("%s,%s", throttle.getLimit(), TIMESTAMP_SERIALIZER.toString(throttle.getExpiration().toEpochMilli()));
}

代码示例来源:origin: bazaarvoice/emodb

@Provides @Singleton @HintsConsistencyTimeValues
Map<String, ValueStore<Long>> provideHintsTimestampValues(@CassandraClusters Collection<String> cassandraClusters,
                             @GlobalFullConsistencyZooKeeper CuratorFramework curator,
                             LifeCycleRegistry lifeCycle)
    throws Exception {
  // Create a timestamp holder for each Cassandra cluster.
  Map<String, ValueStore<Long>> valuesByCluster = Maps.newLinkedHashMap();
  for (String cluster : cassandraClusters) {
    String zkPath = ZKPaths.makePath("/consistency/max-timestamp", cluster);
    ZkValueStore<Long> holder = new ZkValueStore<>(curator, zkPath, new ZkTimestampSerializer());
    valuesByCluster.put(cluster, lifeCycle.manage(holder));
  }
  return valuesByCluster;
}

代码示例来源:origin: com.bazaarvoice.emodb/emodb-sor

@Override
public String toString(StashRunTimeInfo stashRunTimeInfo) {
  return String.format("%s;%s;%s;%s", TIMESTAMP_SERIALIZER.toString(stashRunTimeInfo.getTimestamp()), stashRunTimeInfo.getDataCenter(),
      stashRunTimeInfo.getExpiredTimestamp(), StringUtils.join(stashRunTimeInfo.getPlacements(), ','));
}

代码示例来源:origin: com.bazaarvoice.emodb/emodb-sor

@Override
  public StashRunTimeInfo fromString(String string) {
    if (string == null) {
      return null;
    }
    try {
      List<String> strings = Arrays.asList(StringUtils.split(string, ";"));
      Long timestamp = TIMESTAMP_SERIALIZER.fromString(strings.get(0));
      String dataCenter = strings.get(1);
      Long expiredTimestamp = TIMESTAMP_SERIALIZER.fromString(strings.get(2));
      List<String> placements = Arrays.asList(StringUtils.split(strings.get(3), ","));

      return new StashRunTimeInfo(timestamp, placements, dataCenter, expiredTimestamp);
    } catch (IllegalArgumentException e) {
      throw new IllegalArgumentException("StashRunTimeInfo string must be of the form \"timestamp;datacenter;remote;placement1,placement2,placement3,...\"");
    }
  }
}

代码示例来源:origin: bazaarvoice/emodb

@Provides @Singleton @HintsConsistencyTimeValues
Map<String, ValueStore<Long>> provideHintsTimestampValues(@CassandraClusters Collection<String> cassandraClusters,
                             @GlobalFullConsistencyZooKeeper CuratorFramework curator,
                             LifeCycleRegistry lifeCycle) {
  // Create a timestamp holder for each Cassandra cluster.
  Map<String, ValueStore<Long>> valuesByCluster = Maps.newLinkedHashMap();
  for (String cluster : cassandraClusters) {
    String zkPath = ZKPaths.makePath("/consistency/max-timestamp", cluster);
    ZkValueStore<Long> holder = new ZkValueStore<>(curator, zkPath, new ZkTimestampSerializer());
    valuesByCluster.put(cluster, lifeCycle.manage(holder));
  }
  return valuesByCluster;
}

代码示例来源:origin: bazaarvoice/emodb

@Override
public String toString(StashRunTimeInfo stashRunTimeInfo) {
  return String.format("%s;%s;%s;%s", TIMESTAMP_SERIALIZER.toString(stashRunTimeInfo.getTimestamp()), stashRunTimeInfo.getDataCenter(),
      stashRunTimeInfo.getExpiredTimestamp(), StringUtils.join(stashRunTimeInfo.getPlacements(), ','));
}

代码示例来源:origin: bazaarvoice/emodb

@Override
  public StashRunTimeInfo fromString(String string) {
    if (string == null) {
      return null;
    }
    try {
      List<String> strings = Arrays.asList(StringUtils.split(string, ";"));
      Long timestamp = TIMESTAMP_SERIALIZER.fromString(strings.get(0));
      String dataCenter = strings.get(1);
      Long expiredTimestamp = TIMESTAMP_SERIALIZER.fromString(strings.get(2));
      List<String> placements = Arrays.asList(StringUtils.split(strings.get(3), ","));

      return new StashRunTimeInfo(timestamp, placements, dataCenter, expiredTimestamp);
    } catch (IllegalArgumentException e) {
      throw new IllegalArgumentException("StashRunTimeInfo string must be of the form \"timestamp;datacenter;remote;placement1,placement2,placement3,...\"");
    }
  }
}

代码示例来源:origin: com.bazaarvoice.emodb/emodb-sor

@Provides @Singleton @HintsConsistencyTimeValues
Map<String, ValueStore<Long>> provideHintsTimestampValues(@CassandraClusters Collection<String> cassandraClusters,
                             @GlobalFullConsistencyZooKeeper CuratorFramework curator,
                             LifeCycleRegistry lifeCycle)
    throws Exception {
  // Create a timestamp holder for each Cassandra cluster.
  Map<String, ValueStore<Long>> valuesByCluster = Maps.newLinkedHashMap();
  for (String cluster : cassandraClusters) {
    String zkPath = ZKPaths.makePath("/consistency/max-timestamp", cluster);
    ZkValueStore<Long> holder = new ZkValueStore<>(curator, zkPath, new ZkTimestampSerializer());
    valuesByCluster.put(cluster, lifeCycle.manage(holder));
  }
  return valuesByCluster;
}

代码示例来源:origin: com.bazaarvoice.emodb/emodb-table

@Inject
public HintsConsistencyTimeTask(TaskRegistry taskRegistry, @Maintenance String scope,
                @GlobalFullConsistencyZooKeeper CuratorFramework curator,
                @HintsConsistencyTimeValues Map<String, ValueStore<Long>> timestampCache) {
  super(taskRegistry, scope + "-compaction-timestamp", "Full consistency maximum timestamp",
      timestampCache, curator, new ZkTimestampSerializer(),
      new Supplier<Long>() {
        @Override
        public Long get() {
          return HintsConsistencyTimeProvider.getDefaultTimestamp();
        }
      });
}

代码示例来源:origin: bazaarvoice/emodb

@Inject
public HintsConsistencyTimeTask(TaskRegistry taskRegistry, @Maintenance String scope,
                @GlobalFullConsistencyZooKeeper CuratorFramework curator,
                @HintsConsistencyTimeValues Map<String, ValueStore<Long>> timestampCache) {
  super(taskRegistry, scope + "-compaction-timestamp", "Full consistency maximum timestamp",
      timestampCache, curator, new ZkTimestampSerializer(),
      new Supplier<Long>() {
        @Override
        public Long get() {
          return HintsConsistencyTimeProvider.getDefaultTimestamp();
        }
      });
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com