Tabnine Logo
CommonUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
CommonUtils
in
com.hazelcast.simulator.utils

Best Java code snippets using com.hazelcast.simulator.utils.CommonUtils (Showing top 20 results out of 315)

origin: com.hazelcast.simulator/tests-common

private void delay() {
  if (maxDelayMs != 0) {
    sleepMillis(minDelayMs + random.nextInt(maxDelayMs));
  }
}
origin: com.hazelcast.simulator/tests-common

  @Override
  public void afterCompletion() {
    listeners.add(listener);
    sleepSeconds(PAUSE_FOR_LAST_EVENTS_SECONDS);
  }
}
origin: com.hazelcast.simulator/simulator

@Override
public void close() {
  closeQuietly(connector);
}
origin: com.hazelcast.simulator/simulator

public static void exitWithError(Logger logger, String msg, Throwable throwable) {
  if (throwable instanceof CommandLineExitException) {
    String logMessage = throwable.getMessage();
    if (throwable.getCause() != null) {
      String throwableString = throwableToString(throwable.getCause());
      logMessage += NEW_LINE + throwableString;
    }
    logger.fatal(logMessage);
  } else {
    String throwableString = throwableToString(throwable);
    logger.fatal(msg + NEW_LINE + throwableString);
  }
  exit(1);
}
origin: com.hazelcast.simulator/simulator

  public void shutdown() {
    messageQueue.add(POISON_PILL);
    SimulatorMessage message = messageQueue.peek();
    while (message != null) {
      if (!POISON_PILL.equals(message)) {
        int queueSize = messageQueue.size();
        LOGGER.debug(format("%d messages pending on messageQueue, first message: %s", queueSize, message));
      }
      sleepMillis(WAIT_FOR_EMPTY_QUEUE_MILLIS);
      message = messageQueue.peek();
    }
    joinThread(messageQueueThread);
  }
}
origin: com.hazelcast.simulator/simulator

static Properties getUserProperties() {
  FileInputStream inputStream = null;
  try {
    Properties properties = new Properties();
    File userPropertiesFile = new File(SimulatorProperties.PROPERTIES_FILE_NAME).getAbsoluteFile();
    if (!userPropertiesFile.exists()) {
      return properties;
    }
    inputStream = new FileInputStream(userPropertiesFile);
    properties.load(inputStream);
    return properties;
  } catch (IOException e) {
    throw rethrow(e);
  } finally {
    closeQuietly(inputStream);
  }
}
origin: com.hazelcast.simulator/simulator

private static void printHelpAndExit() {
  System.out.println(
      "Command         Description                                                                 \n"
          + "--------------------------                                                                  \n"
          + "download        Downloads all artifacts from the workers                                    \n"
          + "install         Installs vendor software on the remote machines                             \n"
          + "print-layout    Prints the cluster-layout                                                   \n"
          + "test-run        Runs a test and wait for completion                                         \n"
          + "test-start      Starts a test asynchronously                                                \n"
          + "test-stop       Stops a test                                                                \n"
          + "test-status     Checks the status of a test                                                 \n"
          + "stop            Stops the Coordinator remote session                                        \n"
          + "worker-kill     Kills one or more workers                                                   \n"
          + "worker-script   Executes a script on workers                                                \n"
          + "worker-start    Starts workers                                                              ");
  exitWithError();
}
origin: com.hazelcast.simulator/simulator

public static void main(String[] args) throws Exception {
  CoordinatorRemoteCli cli = null;
  try {
    cli = new CoordinatorRemoteCli(args);
    cli.run();
  } catch (Exception e) {
    System.err.print(e.getMessage());
    exitWithError(LOGGER, e.getMessage(), e);
  } finally {
    closeQuietly(cli);
  }
}
origin: com.hazelcast.simulator/simulator

private void waitForWorkerShutdown(int expectedWorkerCount) {
  int timeoutSeconds = simulatorProperties.getWaitForWorkerShutdownTimeoutSeconds();
  long started = System.nanoTime();
  LOGGER.info(format("Waiting up to %d seconds for shutdown of %d Workers...", timeoutSeconds, expectedWorkerCount));
  long expirationTimeMillis = System.currentTimeMillis() + SECONDS.toMillis(timeoutSeconds);
  while (componentRegistry.workerCount() > 0 && System.currentTimeMillis() < expirationTimeMillis) {
    sleepMillis(FINISHED_WORKERS_SLEEP_MILLIS);
  }
  List<WorkerData> remainingWorkers = componentRegistry.getWorkers();
  if (remainingWorkers.isEmpty()) {
    LOGGER.info(format("Finished shutdown of all Workers (%d seconds)", getElapsedSeconds(started)));
  } else {
    LOGGER.warn(format("Aborted waiting for shutdown of all Workers (%d still running)...", remainingWorkers.size()));
    LOGGER.warn(format("Unfinished workers: %s", toString(remainingWorkers)));
  }
}
origin: com.hazelcast.simulator/simulator

private void rethrowExceptionIfAny() {
  if (storedException != null) {
    throw rethrow(storedException);
  }
}
origin: com.hazelcast.simulator/utils

public static StringBuilder execute(String command) {
  StringBuilder sb = new StringBuilder();
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("Executing bash command: " + command);
  }
  try {
    // create a process for the shell
    ProcessBuilder pb = new ProcessBuilder("bash", "-c", command);
    pb = pb.redirectErrorStream(true);
    Process shell = pb.start();
    new BashStreamGobbler(shell.getInputStream(), sb).start();
    // wait for the shell to finish and get the return code
    int shellExitStatus = shell.waitFor();
    if (shellExitStatus != 0) {
      LOGGER.error(format("Failed to execute [%s]", command));
      LOGGER.error(sb.toString());
      exitWithError();
    } else {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Bash output: " + NEW_LINE + sb);
      }
    }
    return sb;
  } catch (Exception e) {
    throw rethrow(e);
  }
}
origin: com.hazelcast.simulator/simulator

  public static void main(String[] args) {
    LOGGER.info("Hazelcast Simulator Wizard");
    LOGGER.info(format("Version: %s, Commit: %s, Build Time: %s",
        getSimulatorVersion(), getCommitIdAbbrev(), getBuildTime()));

    try {
      WizardCli cli = new WizardCli(args);
      cli.run();
    } catch (Exception e) {
      exitWithError(LOGGER, "Could not execute command", e);
    }
  }
}
origin: com.hazelcast.simulator/utils

    task.run();
  } catch (Exception e) {
    throw rethrow(e);
sleepMillisThrowException(sleepMillis);
sleepMillis *= ASSERT_TRUE_EVENTUALLY_SLEEP_FACTOR;
origin: com.hazelcast.simulator/utils

public static void exitWithError() {
  exit(1);
}
origin: com.hazelcast.simulator/utils

  @Override
  public void run() {
    sleepNanos(sleepNanos);
    callerThread.interrupt();
  }
}
origin: com.hazelcast.simulator/simulator

public FailureOperation(String message, FailureType type, SimulatorAddress workerAddress, String agentAddress,
            Throwable cause) {
  this(message, type, workerAddress, agentAddress, null, null, null, throwableToString(cause));
}
origin: com.hazelcast.simulator/simulator

public static void warmupPartitions(HazelcastInstance hazelcastInstance) {
  LOGGER.info("Waiting for partition warmup");
  PartitionService partitionService = hazelcastInstance.getPartitionService();
  long started = System.nanoTime();
  for (Partition partition : partitionService.getPartitions()) {
    if (System.nanoTime() - started > PARTITION_WARMUP_TIMEOUT_NANOS) {
      throw new IllegalStateException("Partition warmup timeout. Partitions didn't get an owner in time");
    }
    while (partition.getOwner() == null) {
      LOGGER.debug("Partition owner is not yet set for partitionId: " + partition.getPartitionId());
      sleepMillisThrowException(PARTITION_WARMUP_SLEEP_INTERVAL_MILLIS);
    }
  }
  LOGGER.info("Partitions are warmed up successfully");
}
origin: com.hazelcast.simulator/simulator

private EncodableHistogram getIntervalHistogram() {
  EncodableHistogram histogram = null;
  try {
    histogram = logReader.nextIntervalHistogram(config.rangeStartTimeSec, config.rangeEndTimeSec);
  } catch (RuntimeException ex) {
    System.err.println("Log file parsing error at line number " + lineNumber +
        ": line appears to be malformed.");
    if (config.verbose) {
      throw ex;
    } else {
      exitWithError();
    }
  }
  lineNumber++;
  return histogram;
}
origin: com.hazelcast.simulator/simulator

public static void sleepMillisThrowException(int millis) {
  try {
    MILLISECONDS.sleep(millis);
  } catch (InterruptedException e) {
    throw rethrow(e);
  }
}
origin: com.hazelcast.simulator/simulator

void load(File file) {
  FileInputStream inputStream = null;
  try {
    inputStream = new FileInputStream(file);
    properties.load(inputStream);
    if (containsKey("HAZELCAST_VERSION_SPEC")) {
      throw new IOException("'HAZELCAST_VERSION_SPEC' property is deprecated, Use 'VERSION_SPEC' instead.");
    }
  } catch (IOException e) {
    throw rethrow(e);
  } finally {
    closeQuietly(inputStream);
  }
}
com.hazelcast.simulator.utilsCommonUtils

Most used methods

  • sleepMillis
  • sleepSeconds
  • closeQuietly
  • exitWithError
  • exit
  • rethrow
  • sleepMillisThrowException
  • sleepNanos
  • throwableToString
  • await
  • awaitTermination
  • getElapsedSeconds
  • awaitTermination,
  • getElapsedSeconds,
  • getSimulatorVersion,
  • joinThread,
  • sleepRandomNanos,
  • sleepTimeUnit,
  • sleepUntilMs

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • runOnUiThread (Activity)
  • findViewById (Activity)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • JLabel (javax.swing)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now