本文整理了Java中org.apache.samza.util.Util
类的一些代码示例,展示了Util
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util
类的具体详情如下:
包路径:org.apache.samza.util.Util
类名称:Util
暂无
代码示例来源:origin: apache/samza
public CoordinationUtilsFactory getCoordinationUtilsFactory() {
// load the class
String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName();
return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class);
}
代码示例来源:origin: apache/samza
/**
* @return The hostname to use in the hostname field of the encoded
* LoggingEvents.
*/
public static String getHostname() {
try {
return Util.getLocalHost().getHostName();
} catch (Exception e) {
return "unknown-host";
}
}
代码示例来源:origin: apache/samza
static Config mergeConfig(Map<String, String> originalConfig, Map<String, String> generatedConfig) {
Map<String, String> mergedConfig = new HashMap<>(generatedConfig);
originalConfig.forEach((k, v) -> {
if (generatedConfig.containsKey(k) && !Objects.equals(generatedConfig.get(k), v)) {
LOG.info("Replacing generated config for key: {} value: {} with original config value: {}", k, generatedConfig.get(k), v);
}
mergedConfig.put(k, v);
});
return Util.rewriteConfig(new MapConfig(mergedConfig));
}
代码示例来源:origin: org.apache.samza/samza-core_2.12
/**
* Method invoked when the given thread terminates due to the
* given uncaught exception.
* <p>Any exception thrown by this method will be ignored by the
* Java Virtual Machine.
*
* @param t the thread
* @param e the exception
*/
@Override
public void uncaughtException(Thread t, Throwable e) {
String msg = String.format("Uncaught exception in thread %s.", t.getName());
LOGGER.error(msg, e);
System.err.println(msg);
e.printStackTrace(System.err);
try {
Util.logThreadDump("Thread dump from uncaught exception handler.");
runnable.run();
} catch (Throwable throwable) {
// Ignore to avoid further exception propagation
}
}
}
代码示例来源:origin: org.apache.samza/samza-yarn_2.11
/**
* Gets the environment variables from the specified {@link CommandBuilder} and escapes certain characters.
*
* @param cmdBuilder the command builder containing the environment variables.
* @return the map containing the escaped environment variables.
*/
private Map<String, String> getEscapedEnvironmentVariablesMap(CommandBuilder cmdBuilder) {
Map<String, String> env = new HashMap<String, String>();
for (Map.Entry<String, String> entry : cmdBuilder.buildEnvironment().entrySet()) {
String escapedValue = Util.envVarEscape(entry.getValue());
env.put(entry.getKey(), escapedValue);
}
return env;
}
代码示例来源:origin: org.apache.samza/samza-core
/**
* Method invoked when the given thread terminates due to the
* given uncaught exception.
* <p>Any exception thrown by this method will be ignored by the
* Java Virtual Machine.
*
* @param t the thread
* @param e the exception
*/
@Override
public void uncaughtException(Thread t, Throwable e) {
String msg = String.format("Uncaught exception in thread %s.", t.getName());
LOGGER.error(msg, e);
System.err.println(msg);
e.printStackTrace(System.err);
try {
Util.logThreadDump("Thread dump from uncaught exception handler.");
runnable.run();
} catch (Throwable throwable) {
// Ignore to avoid further exception propagation
}
}
}
代码示例来源:origin: org.apache.samza/samza-yarn
/**
* Gets the environment variables from the specified {@link CommandBuilder} and escapes certain characters.
*
* @param cmdBuilder the command builder containing the environment variables.
* @return the map containing the escaped environment variables.
*/
private Map<String, String> getEscapedEnvironmentVariablesMap(CommandBuilder cmdBuilder) {
Map<String, String> env = new HashMap<String, String>();
for (Map.Entry<String, String> entry : cmdBuilder.buildEnvironment().entrySet()) {
String escapedValue = Util.envVarEscape(entry.getValue());
env.put(entry.getKey(), escapedValue);
}
return env;
}
代码示例来源:origin: org.apache.samza/samza-core_2.11
public CoordinationUtilsFactory getCoordinationUtilsFactory() {
// load the class
String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName();
return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class);
}
代码示例来源:origin: apache/samza
/**
* @return The hostname to use in the hostname field of the encoded
* LoggingEvents.
*/
public static String getHostname() {
try {
return Util.getLocalHost().getHostName();
} catch (Exception e) {
return "unknown-host";
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.11
/**
* Method invoked when the given thread terminates due to the
* given uncaught exception.
* <p>Any exception thrown by this method will be ignored by the
* Java Virtual Machine.
*
* @param t the thread
* @param e the exception
*/
@Override
public void uncaughtException(Thread t, Throwable e) {
String msg = String.format("Uncaught exception in thread %s.", t.getName());
LOGGER.error(msg, e);
System.err.println(msg);
e.printStackTrace(System.err);
try {
Util.logThreadDump("Thread dump from uncaught exception handler.");
runnable.run();
} catch (Throwable throwable) {
// Ignore to avoid further exception propagation
}
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.11
static Config mergeConfig(Map<String, String> originalConfig, Map<String, String> generatedConfig) {
Map<String, String> mergedConfig = new HashMap<>(generatedConfig);
originalConfig.forEach((k, v) -> {
if (generatedConfig.containsKey(k) && !Objects.equals(generatedConfig.get(k), v)) {
LOG.info("Replacing generated config for key: {} value: {} with original config value: {}", k, generatedConfig.get(k), v);
}
mergedConfig.put(k, v);
});
return Util.rewriteConfig(new MapConfig(mergedConfig));
}
代码示例来源:origin: org.apache.samza/samza-yarn_2.11
env.put(ShellCommandConfig.ENV_EXECUTION_ENV_CONTAINER_ID(), Util.envVarEscape(container.getId().toString()));
printContainerEnvironmentVariables(samzaContainerId, env);
代码示例来源:origin: org.apache.samza/samza-core_2.10
public CoordinationUtilsFactory getCoordinationUtilsFactory() {
// load the class
String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName();
return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class);
}
代码示例来源:origin: apache/samza
@Override
public LocationIdProvider getLocationIdProvider(Config config) {
return () -> new LocationId(Util.getLocalHost().getHostName());
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.10
/**
* Method invoked when the given thread terminates due to the
* given uncaught exception.
* <p>Any exception thrown by this method will be ignored by the
* Java Virtual Machine.
*
* @param t the thread
* @param e the exception
*/
@Override
public void uncaughtException(Thread t, Throwable e) {
String msg = String.format("Uncaught exception in thread %s.", t.getName());
LOGGER.error(msg, e);
System.err.println(msg);
e.printStackTrace(System.err);
try {
Util.logThreadDump("Thread dump from uncaught exception handler.");
runnable.run();
} catch (Throwable throwable) {
// Ignore to avoid further exception propagation
}
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.10
static Config mergeConfig(Map<String, String> originalConfig, Map<String, String> generatedConfig) {
Map<String, String> mergedConfig = new HashMap<>(generatedConfig);
originalConfig.forEach((k, v) -> {
if (generatedConfig.containsKey(k) && !Objects.equals(generatedConfig.get(k), v)) {
LOG.info("Replacing generated config for key: {} value: {} with original config value: {}", k, generatedConfig.get(k), v);
}
mergedConfig.put(k, v);
});
return Util.rewriteConfig(new MapConfig(mergedConfig));
}
代码示例来源:origin: org.apache.samza/samza-yarn
env.put(ShellCommandConfig.ENV_EXECUTION_ENV_CONTAINER_ID(), Util.envVarEscape(container.getId().toString()));
printContainerEnvironmentVariables(samzaContainerId, env);
代码示例来源:origin: org.apache.samza/samza-core_2.12
public CoordinationUtilsFactory getCoordinationUtilsFactory() {
// load the class
String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName();
return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class);
}
代码示例来源:origin: org.apache.samza/samza-core_2.10
@Override
public LocationIdProvider getLocationIdProvider(Config config) {
return () -> new LocationId(Util.getLocalHost().getHostName());
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.12
public void start() {
if (started) {
LOG.warn("Skipping attempt to start an already started ContainerHeartbeatMonitor.");
return;
}
LOG.info("Starting ContainerHeartbeatMonitor");
scheduler.scheduleAtFixedRate(() -> {
ContainerHeartbeatResponse response = containerHeartbeatClient.requestHeartbeat();
if (!response.isAlive()) {
scheduler.schedule(() -> {
// On timeout of container shutting down, force exit.
LOG.error("Graceful shutdown timeout expired. Force exiting.");
Util.logThreadDump("Thread dump at heartbeat monitor shutdown timeout.");
System.exit(1);
}, SHUTDOWN_TIMOUT_MS, TimeUnit.MILLISECONDS);
onContainerExpired.run();
}
}, 0, SCHEDULE_MS, TimeUnit.MILLISECONDS);
started = true;
}
内容来源于网络,如有侵权,请联系作者删除!