org.apache.samza.util.Util类的使用及代码示例

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

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

Util介绍

暂无

代码示例

代码示例来源:origin: apache/samza

  1. public CoordinationUtilsFactory getCoordinationUtilsFactory() {
  2. // load the class
  3. String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName();
  4. return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class);
  5. }

代码示例来源:origin: apache/samza

  1. /**
  2. * @return The hostname to use in the hostname field of the encoded
  3. * LoggingEvents.
  4. */
  5. public static String getHostname() {
  6. try {
  7. return Util.getLocalHost().getHostName();
  8. } catch (Exception e) {
  9. return "unknown-host";
  10. }
  11. }

代码示例来源:origin: apache/samza

  1. static Config mergeConfig(Map<String, String> originalConfig, Map<String, String> generatedConfig) {
  2. Map<String, String> mergedConfig = new HashMap<>(generatedConfig);
  3. originalConfig.forEach((k, v) -> {
  4. if (generatedConfig.containsKey(k) && !Objects.equals(generatedConfig.get(k), v)) {
  5. LOG.info("Replacing generated config for key: {} value: {} with original config value: {}", k, generatedConfig.get(k), v);
  6. }
  7. mergedConfig.put(k, v);
  8. });
  9. return Util.rewriteConfig(new MapConfig(mergedConfig));
  10. }

代码示例来源:origin: org.apache.samza/samza-core_2.12

  1. /**
  2. * Method invoked when the given thread terminates due to the
  3. * given uncaught exception.
  4. * <p>Any exception thrown by this method will be ignored by the
  5. * Java Virtual Machine.
  6. *
  7. * @param t the thread
  8. * @param e the exception
  9. */
  10. @Override
  11. public void uncaughtException(Thread t, Throwable e) {
  12. String msg = String.format("Uncaught exception in thread %s.", t.getName());
  13. LOGGER.error(msg, e);
  14. System.err.println(msg);
  15. e.printStackTrace(System.err);
  16. try {
  17. Util.logThreadDump("Thread dump from uncaught exception handler.");
  18. runnable.run();
  19. } catch (Throwable throwable) {
  20. // Ignore to avoid further exception propagation
  21. }
  22. }
  23. }

代码示例来源:origin: org.apache.samza/samza-yarn_2.11

  1. /**
  2. * Gets the environment variables from the specified {@link CommandBuilder} and escapes certain characters.
  3. *
  4. * @param cmdBuilder the command builder containing the environment variables.
  5. * @return the map containing the escaped environment variables.
  6. */
  7. private Map<String, String> getEscapedEnvironmentVariablesMap(CommandBuilder cmdBuilder) {
  8. Map<String, String> env = new HashMap<String, String>();
  9. for (Map.Entry<String, String> entry : cmdBuilder.buildEnvironment().entrySet()) {
  10. String escapedValue = Util.envVarEscape(entry.getValue());
  11. env.put(entry.getKey(), escapedValue);
  12. }
  13. return env;
  14. }

代码示例来源:origin: org.apache.samza/samza-core

  1. /**
  2. * Method invoked when the given thread terminates due to the
  3. * given uncaught exception.
  4. * <p>Any exception thrown by this method will be ignored by the
  5. * Java Virtual Machine.
  6. *
  7. * @param t the thread
  8. * @param e the exception
  9. */
  10. @Override
  11. public void uncaughtException(Thread t, Throwable e) {
  12. String msg = String.format("Uncaught exception in thread %s.", t.getName());
  13. LOGGER.error(msg, e);
  14. System.err.println(msg);
  15. e.printStackTrace(System.err);
  16. try {
  17. Util.logThreadDump("Thread dump from uncaught exception handler.");
  18. runnable.run();
  19. } catch (Throwable throwable) {
  20. // Ignore to avoid further exception propagation
  21. }
  22. }
  23. }

代码示例来源:origin: org.apache.samza/samza-yarn

  1. /**
  2. * Gets the environment variables from the specified {@link CommandBuilder} and escapes certain characters.
  3. *
  4. * @param cmdBuilder the command builder containing the environment variables.
  5. * @return the map containing the escaped environment variables.
  6. */
  7. private Map<String, String> getEscapedEnvironmentVariablesMap(CommandBuilder cmdBuilder) {
  8. Map<String, String> env = new HashMap<String, String>();
  9. for (Map.Entry<String, String> entry : cmdBuilder.buildEnvironment().entrySet()) {
  10. String escapedValue = Util.envVarEscape(entry.getValue());
  11. env.put(entry.getKey(), escapedValue);
  12. }
  13. return env;
  14. }

代码示例来源:origin: org.apache.samza/samza-core_2.11

  1. public CoordinationUtilsFactory getCoordinationUtilsFactory() {
  2. // load the class
  3. String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName();
  4. return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class);
  5. }

代码示例来源:origin: apache/samza

  1. /**
  2. * @return The hostname to use in the hostname field of the encoded
  3. * LoggingEvents.
  4. */
  5. public static String getHostname() {
  6. try {
  7. return Util.getLocalHost().getHostName();
  8. } catch (Exception e) {
  9. return "unknown-host";
  10. }
  11. }

代码示例来源:origin: org.apache.samza/samza-core_2.11

  1. /**
  2. * Method invoked when the given thread terminates due to the
  3. * given uncaught exception.
  4. * <p>Any exception thrown by this method will be ignored by the
  5. * Java Virtual Machine.
  6. *
  7. * @param t the thread
  8. * @param e the exception
  9. */
  10. @Override
  11. public void uncaughtException(Thread t, Throwable e) {
  12. String msg = String.format("Uncaught exception in thread %s.", t.getName());
  13. LOGGER.error(msg, e);
  14. System.err.println(msg);
  15. e.printStackTrace(System.err);
  16. try {
  17. Util.logThreadDump("Thread dump from uncaught exception handler.");
  18. runnable.run();
  19. } catch (Throwable throwable) {
  20. // Ignore to avoid further exception propagation
  21. }
  22. }
  23. }

代码示例来源:origin: org.apache.samza/samza-core_2.11

  1. static Config mergeConfig(Map<String, String> originalConfig, Map<String, String> generatedConfig) {
  2. Map<String, String> mergedConfig = new HashMap<>(generatedConfig);
  3. originalConfig.forEach((k, v) -> {
  4. if (generatedConfig.containsKey(k) && !Objects.equals(generatedConfig.get(k), v)) {
  5. LOG.info("Replacing generated config for key: {} value: {} with original config value: {}", k, generatedConfig.get(k), v);
  6. }
  7. mergedConfig.put(k, v);
  8. });
  9. return Util.rewriteConfig(new MapConfig(mergedConfig));
  10. }

代码示例来源:origin: org.apache.samza/samza-yarn_2.11

  1. env.put(ShellCommandConfig.ENV_EXECUTION_ENV_CONTAINER_ID(), Util.envVarEscape(container.getId().toString()));
  2. printContainerEnvironmentVariables(samzaContainerId, env);

代码示例来源:origin: org.apache.samza/samza-core_2.10

  1. public CoordinationUtilsFactory getCoordinationUtilsFactory() {
  2. // load the class
  3. String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName();
  4. return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class);
  5. }

代码示例来源:origin: apache/samza

  1. @Override
  2. public LocationIdProvider getLocationIdProvider(Config config) {
  3. return () -> new LocationId(Util.getLocalHost().getHostName());
  4. }
  5. }

代码示例来源:origin: org.apache.samza/samza-core_2.10

  1. /**
  2. * Method invoked when the given thread terminates due to the
  3. * given uncaught exception.
  4. * <p>Any exception thrown by this method will be ignored by the
  5. * Java Virtual Machine.
  6. *
  7. * @param t the thread
  8. * @param e the exception
  9. */
  10. @Override
  11. public void uncaughtException(Thread t, Throwable e) {
  12. String msg = String.format("Uncaught exception in thread %s.", t.getName());
  13. LOGGER.error(msg, e);
  14. System.err.println(msg);
  15. e.printStackTrace(System.err);
  16. try {
  17. Util.logThreadDump("Thread dump from uncaught exception handler.");
  18. runnable.run();
  19. } catch (Throwable throwable) {
  20. // Ignore to avoid further exception propagation
  21. }
  22. }
  23. }

代码示例来源:origin: org.apache.samza/samza-core_2.10

  1. static Config mergeConfig(Map<String, String> originalConfig, Map<String, String> generatedConfig) {
  2. Map<String, String> mergedConfig = new HashMap<>(generatedConfig);
  3. originalConfig.forEach((k, v) -> {
  4. if (generatedConfig.containsKey(k) && !Objects.equals(generatedConfig.get(k), v)) {
  5. LOG.info("Replacing generated config for key: {} value: {} with original config value: {}", k, generatedConfig.get(k), v);
  6. }
  7. mergedConfig.put(k, v);
  8. });
  9. return Util.rewriteConfig(new MapConfig(mergedConfig));
  10. }

代码示例来源:origin: org.apache.samza/samza-yarn

  1. env.put(ShellCommandConfig.ENV_EXECUTION_ENV_CONTAINER_ID(), Util.envVarEscape(container.getId().toString()));
  2. printContainerEnvironmentVariables(samzaContainerId, env);

代码示例来源:origin: org.apache.samza/samza-core_2.12

  1. public CoordinationUtilsFactory getCoordinationUtilsFactory() {
  2. // load the class
  3. String coordinationUtilsFactoryClass = getJobCoordinationUtilsFactoryClassName();
  4. return Util.getObj(coordinationUtilsFactoryClass, CoordinationUtilsFactory.class);
  5. }

代码示例来源:origin: org.apache.samza/samza-core_2.10

  1. @Override
  2. public LocationIdProvider getLocationIdProvider(Config config) {
  3. return () -> new LocationId(Util.getLocalHost().getHostName());
  4. }
  5. }

代码示例来源:origin: org.apache.samza/samza-core_2.12

  1. public void start() {
  2. if (started) {
  3. LOG.warn("Skipping attempt to start an already started ContainerHeartbeatMonitor.");
  4. return;
  5. }
  6. LOG.info("Starting ContainerHeartbeatMonitor");
  7. scheduler.scheduleAtFixedRate(() -> {
  8. ContainerHeartbeatResponse response = containerHeartbeatClient.requestHeartbeat();
  9. if (!response.isAlive()) {
  10. scheduler.schedule(() -> {
  11. // On timeout of container shutting down, force exit.
  12. LOG.error("Graceful shutdown timeout expired. Force exiting.");
  13. Util.logThreadDump("Thread dump at heartbeat monitor shutdown timeout.");
  14. System.exit(1);
  15. }, SHUTDOWN_TIMOUT_MS, TimeUnit.MILLISECONDS);
  16. onContainerExpired.run();
  17. }
  18. }, 0, SCHEDULE_MS, TimeUnit.MILLISECONDS);
  19. started = true;
  20. }

相关文章