static boolean isMinVersion(String minVersion, String version) { if (version == null) { return false; } return VersionUtils.isMinVersion(minVersion, getVersion()); }
static String getHazelcastVersionFromJarOrNull(String classPath) { try { List<File> jarFiles = getFilesFromClassPath(classPath); for (File jarFile : jarFiles) { String version = getVersion(jarFile); if (version != null) { return version; } } } catch (UncheckedIOException ignored) { ignore(ignored); } return null; }
private void executeInitScript(String ip) { File initFile = newFile("init-" + newUnsecureUuidString() + ".sh"); writeText(loadInitScript(), initFile); bash.scpToRemote(ip, initFile, "init.sh"); bash.sshTTY(ip, "bash init.sh"); deleteQuiet(initFile); }
public static void checkInstallation(Bash bash, SimulatorProperties properties, ComponentRegistry registry) { if (runMode(properties) != RunMode.Remote) { return; } ThreadSpawner spawner = new ThreadSpawner("checkInstallation", true); for (AgentData agentData : registry.getAgents()) { spawner.spawn(new CheckAgentInstallationTask(agentData, bash)); } spawner.awaitCompletion(); }
private void createPidFile() { deleteQuiet(pidFile); writeText("" + getPID(), pidFile); }
ProvisionerCli(String[] args) { this.options = initOptionsWithHelp(parser, args); SimulatorProperties properties = loadSimulatorProperties(); ComputeService computeService = isCloudProvider(properties) ? new ComputeServiceBuilder(properties).build() : null; Bash bash = new Bash(properties); this.tags = loadTags(options, tagsSpec); this.provisioner = new Provisioner(properties, computeService, bash); }
public static void assertCompletesEventually(final Future f) { assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { assertTrue("future has not completed", f.isDone()); } }); }
private static HazelcastInstanceImpl getHazelcastInstanceImpl(HazelcastInstance hz) { HazelcastInstanceImpl impl = null; if (hz instanceof HazelcastInstanceProxy) { return getFieldValue(hz, "original"); } else if (hz instanceof HazelcastInstanceImpl) { impl = (HazelcastInstanceImpl) hz; } return impl; }
ReportExceptionThread(String testId, String name, Runnable task) { super(task, name); this.testId = testId; setDaemon(true); }
public static RuntimeException rethrow(Throwable throwable) { if (throwable instanceof RuntimeException) { throw (RuntimeException) throwable; } else { throw new CommandLineExitException(throwable); } }
/** * Creates a {@link ThreadSpawner} which can report exceptions to the {@link ExceptionReporter} or throw them directly. * * @param identifier identifier to give reported exceptions a context * @param throwException <code>true</code> if exceptions should be directly thrown, * <code>false</code> if {@link ExceptionReporter} should be used */ public ThreadSpawner(String identifier, boolean throwException) { this.identifier = identifier; this.throwException = throwException; this.exceptionHandler = initExceptionHandler(throwException); }
/** * Formats an IP address by adding padding to the left. * * @param ipAddress the IP address * @return the formatted IP address */ public static String formatIpAddress(String ipAddress) { return padLeft(ipAddress, IP_ADDRESS_LENGTH); }
private void rethrowExceptionIfAny() { if (storedException != null) { throw rethrow(storedException); } }
/** * Formats a percentage of two numbers and adds padding to the left. * * @param value the value of the percentage * @param baseValue the base value of the percentage * @return the formatted percentage */ public static String formatPercentage(long value, long baseValue) { double percentage = (baseValue > 0 ? (ONE_HUNDRED * value) / baseValue : 0); return formatDouble(percentage, PERCENTAGE_FORMAT_LENGTH); }
private static String getMetronomeClass(Class<? extends Metronome> metronomeClass) { if (metronomeClass == EmptyMetronome.class) { return null; } return getClassName(metronomeClass); }
ReportExceptionThread(String testId, String name, Runnable task) { super(task, name); this.testId = testId; setDaemon(true); }
public static RuntimeException rethrow(Throwable throwable) { if (throwable instanceof RuntimeException) { throw (RuntimeException) throwable; } else { throw new CommandLineExitException(throwable); } }
/** * Creates a {@link ThreadSpawner} which can report exceptions to the {@link ExceptionReporter} or throw them directly. * * @param testId testId to give reported exceptions a context * @param throwException <code>true</code> if exceptions should be directly thrown, * <code>false</code> if {@link ExceptionReporter} should be used */ public ThreadSpawner(String testId, boolean throwException) { this.testId = testId; this.throwException = throwException; this.exceptionHandler = initExceptionHandler(throwException); }