congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CommonUtils.closeQuietly
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: com.hazelcast.simulator/simulator

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

public static void closeQuietly(Closeable... closeables) {
  for (Closeable c : closeables) {
    closeQuietly(c);
  }
}
origin: com.hazelcast.simulator/simulator

public static void closeQuietly(Closeable... closeables) {
  for (Closeable c : closeables) {
    closeQuietly(c);
  }
}
origin: com.hazelcast.simulator/simulator

  @Override
  public void run() {
    try {
      String line;
      while ((line = reader.readLine()) != null) {
        LOGGER.trace(line);
        stringBuilder.append(line).append(NEW_LINE);
      }
    } catch (IOException ignored) {
      EmptyStatement.ignore(ignored);
    } finally {
      closeQuietly(reader);
      closeQuietly(inputStreamReader);
    }
  }
}
origin: com.hazelcast.simulator/utils

  @Override
  public void run() {
    try {
      String line;
      while ((line = reader.readLine()) != null) {
        stringBuilder.append(line).append(NEW_LINE);
      }
    } catch (IOException ignored) {
      EmptyStatement.ignore(ignored);
    } finally {
      closeQuietly(reader);
      closeQuietly(inputStreamReader);
    }
  }
}
origin: com.hazelcast.simulator/simulator

public static String fileAsText(File file) {
  FileInputStream stream = null;
  InputStreamReader streamReader = null;
  BufferedReader reader = null;
  try {
    stream = new FileInputStream(file);
    streamReader = new InputStreamReader(stream);
    reader = new BufferedReader(streamReader);
    StringBuilder builder = new StringBuilder();
    char[] buffer = new char[READ_BUFFER_SIZE];
    int read;
    while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
      builder.append(buffer, 0, read);
    }
    return builder.toString();
  } catch (IOException e) {
    throw new UncheckedIOException(e);
  } finally {
    closeQuietly(reader);
    closeQuietly(streamReader);
    closeQuietly(stream);
  }
}
origin: com.hazelcast.simulator/simulator

@SuppressFBWarnings("DM_DEFAULT_ENCODING")
private static Properties loadProperties(File file) {
  FileReader reader = null;
  try {
    reader = new FileReader(file);
    Properties properties = new Properties();
    properties.load(reader);
    return properties;
  } catch (IOException e) {
    throw new CommandLineExitException(format("Failed to load TestSuite property file [%s]", file.getAbsolutePath()), e);
  } finally {
    closeQuietly(reader);
  }
}
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

static Properties loadGitProperties(String fileName) {
  Properties properties = new Properties();
  InputStream inputStream = GitInfo.class.getClassLoader().getResourceAsStream(fileName);
  try {
    properties.load(inputStream);
    return properties;
  } catch (NullPointerException e) {
    LOGGER.trace("Error while loading Git properties from " + fileName, e);
  } catch (Exception e) {
    LOGGER.warn("Error while loading Git properties from " + fileName, e);
  } finally {
    closeQuietly(inputStream);
  }
  return new UnknownGitProperties();
}
origin: com.hazelcast.simulator/utils

public static String getText(String url) {
  try {
    URL website = new URL(url);
    URLConnection connection = website.openConnection();
    InputStreamReader streamReader = null;
    BufferedReader reader = null;
    try {
      streamReader = new InputStreamReader(connection.getInputStream());
      reader = new BufferedReader(streamReader);
      StringBuilder response = new StringBuilder();
      String inputLine;
      while ((inputLine = reader.readLine()) != null) {
        response.append(inputLine);
      }
      return response.toString();
    } finally {
      closeQuietly(reader);
      closeQuietly(streamReader);
    }
  } catch (IOException e) {
    throw new UncheckedIOException(e);
  }
}
origin: com.hazelcast.simulator/simulator

public static void appendText(String text, File file) {
  checkNotNull(text, "Text can't be null");
  checkNotNull(file, "File can't be null");
  FileOutputStream stream = null;
  OutputStreamWriter streamWriter = null;
  BufferedWriter writer = null;
  try {
    stream = new FileOutputStream(file, true);
    streamWriter = new OutputStreamWriter(stream);
    writer = new BufferedWriter(streamWriter);
    writer.append(text);
    writer.close();
  } catch (IOException e) {
    throw new UncheckedIOException("Could not append text", e);
  } finally {
    closeQuietly(writer);
    closeQuietly(streamWriter);
    closeQuietly(stream);
  }
}
origin: com.hazelcast.simulator/simulator

public static void copy(File file, OutputStream outputStream) {
  InputStream inputStream = null;
  try {
    inputStream = new FileInputStream(file);
    byte[] buffer = new byte[COPY_BUFFER_SIZE];
    while (true) {
      int readCount = inputStream.read(buffer);
      if (readCount < 0) {
        break;
      }
      outputStream.write(buffer, 0, readCount);
    }
  } catch (IOException e) {
    throw new UncheckedIOException(e);
  } finally {
    closeQuietly(inputStream);
  }
}
origin: com.hazelcast.simulator/utils

public static void copy(File file, OutputStream outputStream) {
  InputStream inputStream = null;
  try {
    inputStream = new FileInputStream(file);
    byte[] buffer = new byte[COPY_BUFFER_SIZE];
    while (true) {
      int readCount = inputStream.read(buffer);
      if (readCount < 0) {
        break;
      }
      outputStream.write(buffer, 0, readCount);
    }
  } catch (IOException e) {
    throw new UncheckedIOException(e);
  } finally {
    closeQuietly(inputStream);
  }
}
origin: com.hazelcast.simulator/simulator

public static void writeText(String text, File file) {
  checkNotNull(text, "Text can't be null");
  checkNotNull(file, "File can't be null");
  FileOutputStream stream = null;
  OutputStreamWriter streamWriter = null;
  BufferedWriter writer = null;
  try {
    stream = new FileOutputStream(file);
    streamWriter = new OutputStreamWriter(stream);
    writer = new BufferedWriter(streamWriter);
    writer.write(text);
    writer.close();
  } catch (IOException e) {
    throw new UncheckedIOException(e);
  } finally {
    closeQuietly(writer);
    closeQuietly(streamWriter);
    closeQuietly(stream);
  }
}
origin: com.hazelcast.simulator/utils

public static void writeText(String text, File file) {
  checkNotNull(text, "Text can't be null");
  checkNotNull(file, "File can't be null");
  FileOutputStream stream = null;
  OutputStreamWriter streamWriter = null;
  BufferedWriter writer = null;
  try {
    stream = new FileOutputStream(file);
    streamWriter = new OutputStreamWriter(stream);
    writer = new BufferedWriter(streamWriter);
    writer.write(text);
    writer.close();
  } catch (IOException e) {
    throw new UncheckedIOException(e);
  } finally {
    closeQuietly(writer);
    closeQuietly(streamWriter);
    closeQuietly(stream);
  }
}
origin: com.hazelcast.simulator/utils

public static void appendText(String text, File file) {
  checkNotNull(text, "Text can't be null");
  checkNotNull(file, "File can't be null");
  FileOutputStream stream = null;
  OutputStreamWriter streamWriter = null;
  BufferedWriter writer = null;
  try {
    stream = new FileOutputStream(file, true);
    streamWriter = new OutputStreamWriter(stream);
    writer = new BufferedWriter(streamWriter);
    writer.append(text);
    writer.close();
  } catch (IOException e) {
    throw new UncheckedIOException("Could not append text", e);
  } finally {
    closeQuietly(writer);
    closeQuietly(streamWriter);
    closeQuietly(stream);
  }
}
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);
  }
}
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/visualiser

@Override
protected BenchmarkResults doInBackground() throws Exception {
  FileInputStream fileInputStream = null;
  try {
    fileInputStream = new FileInputStream(file);
    Map<String, Result> probeResultMap = ProbesResultXmlReader.read(fileInputStream);
    String filename = getFileName(file);
    BenchmarkResults benchmarkResults = new BenchmarkResults(filename);
    for (Map.Entry<String, Result> entry : probeResultMap.entrySet()) {
      benchmarkResults.addProbeData(entry.getKey(), entry.getValue());
    }
    return benchmarkResults;
  } finally {
    closeQuietly(fileInputStream);
  }
}
origin: com.hazelcast.simulator/simulator

@Override
public void close() {
  stopTests();
  if (client != null) {
    new TerminateWorkersTask(simulatorProperties, componentRegistry, client).run();
  }
  closeQuietly(client);
  closeQuietly(connector);
  stopAgents(LOGGER, bash, simulatorProperties, componentRegistry);
  if (!parameters.skipDownload()) {
    new ArtifactDownloadTask(
        parameters.getSessionId(),
        simulatorProperties,
        outputDirectory,
        componentRegistry).run();
    if (parameters.getAfterCompletionFile() != null) {
      echoLocal("Executing after-completion script: " + parameters.getAfterCompletionFile());
      bash.execute(parameters.getAfterCompletionFile() + " " + outputDirectory.getAbsolutePath());
      echoLocal("Finished after-completion script");
    }
  }
  OperationTypeCounter.printStatistics();
  failureCollector.logFailureInfo();
}
com.hazelcast.simulator.utilsCommonUtilscloseQuietly

Popular methods of CommonUtils

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

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setScale (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Best plugins for Eclipse
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