本文整理汇总了Java中com.twitter.util.Duration.apply方法的典型用法代码示例。如果您正苦于以下问题:Java Duration.apply方法的具体用法?Java Duration.apply怎么用?Java Duration.apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.twitter.util.Duration
的用法示例。
在下文中一共展示了Duration.apply方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startAdminHttpService
import com.twitter.util.Duration; //导入方法依赖的package包/类
public void startAdminHttpService() {
try {
Properties properties = new Properties();
properties.load(this.getClass().getResource("build.properties").openStream());
LOG.info("build.properties build_revision: {}",
properties.getProperty("build_revision", "unknown"));
} catch (Throwable t) {
LOG.warn("Failed to load properties from build.properties", t);
}
Duration[] defaultLatchIntervals = {Duration.apply(1, TimeUnit.MINUTES)};
Iterator<Duration> durationIterator = Arrays.asList(defaultLatchIntervals).iterator();
@SuppressWarnings("deprecation")
AdminServiceFactory adminServiceFactory = new AdminServiceFactory(
this.port,
20,
List$.MODULE$.empty(),
Option.empty(),
List$.MODULE$.empty(),
Map$.MODULE$.empty(),
JavaConversions.asScalaIterator(durationIterator).toList());
RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironment(this);
AdminHttpService service = adminServiceFactory.apply(runtimeEnvironment);
for (Map.Entry<String, CustomHttpHandler> entry : this.customHttpHandlerMap.entrySet()) {
service.httpServer().createContext(entry.getKey(), entry.getValue());
}
}
示例2: start
import com.twitter.util.Duration; //导入方法依赖的package包/类
public void start() {
Duration[] defaultLatchIntervals = {Duration.apply(1, TimeUnit.MINUTES)};
@SuppressWarnings("deprecation")
AdminServiceFactory adminServiceFactory = new AdminServiceFactory(
this.mPort,
20,
List$.MODULE$.<StatsFactory>empty(),
Option.<String>empty(),
List$.MODULE$.<Regex>empty(),
Map$.MODULE$.<String, CustomHttpHandler>empty(),
List.<Duration>fromArray(defaultLatchIntervals));
RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironment(this);
AdminHttpService service = adminServiceFactory.apply(runtimeEnvironment);
for (Map.Entry<String, CustomHttpHandler> entry : this.mCustomHttpHandlerMap.entrySet()) {
service.httpServer().createContext(entry.getKey(), entry.getValue());
}
}
示例3: start
import com.twitter.util.Duration; //导入方法依赖的package包/类
public void start() {
Duration[] defaultLatchIntervals = {Duration.apply(1, TimeUnit.MINUTES)};
@SuppressWarnings("deprecation")
AdminServiceFactory adminServiceFactory = new AdminServiceFactory(
this.mPort,
20,
List$.MODULE$.<StatsFactory>empty(),
Option.<String>empty(),
List$.MODULE$.<Regex>empty(),
Map$.MODULE$.<String, CustomHttpHandler>empty(),
List.<Duration>fromArray(defaultLatchIntervals));
RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironment(this);
AdminHttpService service = adminServiceFactory.apply(runtimeEnvironment);
for (Map.Entry<String, CustomHttpHandler> entry: this.mCustomHttpHandlerMap.entrySet()) {
service.httpServer().createContext(entry.getKey(), entry.getValue());
}
}
示例4: start
import com.twitter.util.Duration; //导入方法依赖的package包/类
public void start() {
Duration[] defaultLatchIntervals = {Duration.apply(1, TimeUnit.MINUTES)};
@SuppressWarnings("deprecation")
AdminServiceFactory adminServiceFactory = new AdminServiceFactory(
this.mPort,
20,
List$.MODULE$.<StatsFactory>empty(),
Option.<String>empty(),
List$.MODULE$.<Regex>empty(),
Map$.MODULE$.<String, CustomHttpHandler>empty(),
List.<Duration>fromArray(defaultLatchIntervals)
);
RuntimeEnvironment runtimeEnvironment = new RuntimeEnvironment(this);
adminServiceFactory.apply(runtimeEnvironment);
try {
Properties properties = new Properties();
properties.load(this.getClass().getResource("build.properties").openStream());
String buildRevision = properties.getProperty("build_revision", "unknown");
LOG.info("build.properties build_revision: {}",
properties.getProperty("build_revision", "unknown"));
StatsUtil.setLabel("secor.build_revision", buildRevision);
} catch (Throwable t) {
LOG.error("Failed to load properties from build.properties", t);
}
}
示例5: LindenClient
import com.twitter.util.Duration; //导入方法依赖的package包/类
public LindenClient(String clusterUrl, int timeout, final boolean roundRobin) {
this.timeout = timeout;
this.duration = Duration.apply(timeout, TimeUnit.MILLISECONDS);
LindenZKPathManager zkPathManager = new LindenZKPathManager(clusterUrl);
zkClient = ZKClientFactory.getClient(zkPathManager.getZK());
nodesPath = zkPathManager.getAllNodesPath();
List<String> children = zkClient.getChildren(nodesPath);
zkListener = new LindenZKListener(nodesPath, children) {
@Override
public void onChildChange(String parent, List<String> children, List<String> newAdded, List<String> deleted) {
if (children == null || children.isEmpty()) {
return;
}
if (!roundRobin) {
Collections.sort(children);
String firstNode = children.get(0);
LindenService.ServiceIface leader = clients.get(firstNode);
if (leader == null) {
leader = buildClient(parent, firstNode);
clients.put(firstNode, leader);
LOGGER.info("Linden client [{}] is selected as leader.", parent);
}
clientIface = new SingleClient(leader);
return;
}
Map<String, LindenService.ServiceIface> tmpClients = new ConcurrentHashMap<>();
for (String child : children) {
if (!clients.containsKey(child)) {
clients.put(child, buildClient(parent, child));
LOGGER.info("Linden client [{}] joined to the cluster.", parent);
}
tmpClients.put(child, clients.get(child));
}
for (String delete : deleted) {
clients.remove(delete);
}
clientIface = new RoundRobinClient(tmpClients.values());
}
};
zkClient.subscribeChildChanges(nodesPath, zkListener);
}
示例6: ClusterAnnouncer
import com.twitter.util.Duration; //导入方法依赖的package包/类
public ClusterAnnouncer(LindenConfig lindenConf) {
this.lindenConf = lindenConf;
zkPathManager = new LindenZKPathManager(lindenConf.getClusterUrl());
ZkClientFactory factory = new ZkClientFactory(Duration.apply(30, TimeUnit.SECONDS));
announcer = new ZkAnnouncer(factory);
}
示例7: getByte
import com.twitter.util.Duration; //导入方法依赖的package包/类
/**
* Get the next value in the queue
*
* @param queueName
* @param waitFor
* @return the next value
*/
public byte[] getByte(String queueName, int waitFor) {
final Duration waitDuration = Duration.apply(waitFor, TimeUnit.MILLISECONDS);
return getByte(queueName, waitDuration);
}
示例8: get
import com.twitter.util.Duration; //导入方法依赖的package包/类
/**
* Get the next value in the queue
*
* @param queueName
* @param waitFor
* @return the next value
*/
public String get(String queueName, int waitFor) {
final Duration waitDuration = Duration.apply(waitFor, TimeUnit.MILLISECONDS);
return get(queueName, waitDuration);
}
示例9: peek
import com.twitter.util.Duration; //导入方法依赖的package包/类
/**
* The next value without popping it
*
* @param queueName
* @param waitFor
* an amount of time to wait before returning null
* @return the next value
*/
public String peek(String queueName, int waitFor) {
final Duration waitDuration = Duration.apply(waitFor, TimeUnit.MILLISECONDS);
return peek(queueName, waitDuration);
}
示例10: peekByte
import com.twitter.util.Duration; //导入方法依赖的package包/类
/**
* The next value without popping it
*
* @param queueName
* @param waitFor
* an amount of time to wait before returning null
* @return the next value
*/
public byte[] peekByte(String queueName, int waitFor) {
final Duration waitDuration = Duration.apply(waitFor, TimeUnit.MILLISECONDS);
return peekByte(queueName, waitDuration);
}