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

How to use
Reporter
in
net.sergeych.tools

Best Java code snippets using net.sergeych.tools.Reporter (Showing top 20 results out of 315)

origin: UniversaBlockchain/universa

public ClientNetwork(String nodeUrl, PrivateKey privateKey, BasicHttpClientSession session) throws IOException {
  client = new Client(nodeUrl, privateKey, session);
  if (client == null)
    throw new IOException("failed to connect to to the universa network");
  reporter.verbose("Read Universa network configuration: " + client.size() + " nodes");
  reporter.message("Network version: " + client.getVersion());
}
origin: UniversaBlockchain/universa

private static void finish() {
  finish(reporter.getErrors().size());
}
origin: UniversaBlockchain/universa

static public BasicHttpClientSession getSession(int nodeNumber) throws IOException {
  if (session == null) {
    String keyFileName = prefs.get("session_" + nodeNumber, null);
    if (keyFileName != null) {
      reporter.verbose("Loading session from " + keyFileName);
      try {
        session = BasicHttpClientSession.reconstructSession(Boss.unpack(Do.read(keyFileName)));
      } catch(FileNotFoundException e) {
        // it is ok - session is not reconstructed
      } catch (Exception e) {
        reporter.warning("can't read session file: " + keyFileName);
        e.printStackTrace();
      }
    } else {
      reporter.verbose("No session found at the prefs ");
    }
  }
  return session;
}
origin: UniversaBlockchain/universa

public ClientNetwork(BasicHttpClientSession session, boolean delayedStart) throws IOException {
  for (int i = 1; i < 10; i++) {
    try {
      client = new Client("http://node-" +
          Do.randomIntInRange(1, 10) +
          "-com.universa.io:8080", CLIMain.getPrivateKey(), session, delayedStart);
      break;
    } catch (IOException e) {
      reporter.warning("failed to read network from node " + i);
    }
  }
  if (client == null)
    throw new IOException("failed to connect to to the universa network");
  reporter.verbose("Read Universa network configuration: " + client.size() + " nodes");
  reporter.message("Network version: " + client.getVersion());
}
origin: UniversaBlockchain/universa

public void verbose(String text) {
  if (verboseMode)
    message(text);
}
origin: UniversaBlockchain/universa

  reporter.message("The capsule is not sealed properly:");
  contract.getErrors().forEach(e -> reporter.error(e.getError().toString(), e.getObjectName(), e.getMessage()));
if (reporter.isVerboseMode()) {
        reporter.error(Errors.BAD_REVOKE.name(), r.getId().toString(), "revocation not allowed");
    } catch (Exception clientError) {
      clientError.printStackTrace();
    reporter.newLine();
origin: UniversaBlockchain/universa

      es.submit(() -> {
        final String url = nodes.get(nodeNumber).url;
        reporter.verbose("Checking node " + url);
        for (int i = 0; i < 5; i++) {
          try {
            if (client.ping(nodeNumber)) {
              okNodes.getAndIncrement();
              reporter.verbose("Got an answer from " + url);
              return;
            reporter.message("retry #" + (i+1) + " on connection failure: " + url);
            Thread.sleep(200);
          } catch (InterruptedException e) {
        reporter.error(Errors.NOT_READY.name(), url, "failed to connect");
      })
  );
    f.get(4, TimeUnit.SECONDS);
  } catch (TimeoutException e) {
    reporter.verbose("node test is timed out");
    f.cancel(true);
  } catch (Exception e) {
int n = okNodes.get();
if (n >= client.size() * 0.12)
  reporter.message("Universa network is active, " + n + " node(s) are reachable");
else
  reporter.error("NOT_READY", "network", "Universa network is temporarily inaccessible, reachable nodes: " + n);
origin: UniversaBlockchain/universa

            reporter.warning("errors from " + c.getNodeNumber() + ": " + r.errors);
          break;
});
if (consensus[0] != null)
  reporter.message("State consensus found:" + consensus[0]);
else {
  reporter.warning("no consensus found " + states.size());
      .forEach(kv -> {
        List<ItemResult> itemResults = kv.getValue();
        reporter.message("" + kv.getKey() + ": " + itemResults.size() + ": " +
                     itemResults.stream()
                         .map(x -> x.meta.getStringOrThrow("url"))
origin: UniversaBlockchain/universa

/**
 * Check bytes is contract. And if bytes is, check contract for errors. Print errors if found.
 *
 * @param data - data to check.
 *
 * @return true if bytes is Contract and Contract is valid.
 */
private static Boolean checkBytesIsValidContract(byte[] data) {
  try {
    Contract contract = new Contract(data);
    if (!contract.isOk()) {
      reporter.message("The capsule is not sealed");
      contract.getErrors().forEach(e -> reporter.error(e.getError().toString(), e.getObjectName(), e.getMessage()));
    }
    checkContract(contract);
  } catch (RuntimeException e) {
    addError(Errors.BAD_VALUE.name(), "byte[] data", e.getMessage());
    return false;
  } catch (Quantiser.QuantiserException e) {
    addError("QUANTIZER_COST_LIMIT", "", e.toString());
  } catch (IOException e) {
    addError(Errors.BAD_VALUE.name(), "byte[] data", e.getMessage());
    return false;
  }
  return true;
}
origin: UniversaBlockchain/universa

Config.forceInit(Parcel.class);
reporter.clear();
    reporter.setQuiet(true);
  } else {
    reporter.setQuiet(false);
    usage("No options: " + e.getMessage());
} catch (Finished e) {
  if (reporter.isQuiet())
    System.out.println(reporter.reportJson());
  if(!options.has("no-exit")) {
    System.exit(e.getStatus());
origin: UniversaBlockchain/universa

/**
 * Outputs newline on the console only (does nothing in quiet more).
 */
public void newLine() {
  console("\n");
}
origin: UniversaBlockchain/universa

private static void addError(String code, String object, String message) {
  reporter.error(code, object, message);
}
origin: UniversaBlockchain/universa

@Test
public void checkTheNetwork() throws Exception {
  Reporter r = callMain("--network", "--verbose");
  assertThat(r.getMessage(-1) +
          r.getMessage(-2) +
          r.getMessage(-3) +
          r.getMessage(-4) +
          r.getMessage(-5),
      matches("3 node"));
}
origin: UniversaBlockchain/universa

  @Test
  public void checkNetwork() throws Exception {
    ClientNetwork n = new ClientNetwork(null);
    assertEquals(36, n.size());

    ConsoleInterceptor.copyOut(() -> {
      int active = n.checkNetworkState(new Reporter());
      assertEquals(36, active);
    });
  }
}
origin: UniversaBlockchain/universa

String keyFileName = prefs.get("privateKeyFile", null);
if (keyFileName != null) {
  reporter.verbose("Loading private key from " + keyFileName);
  try {
    privateKey = new PrivateKey(Do.read(keyFileName));
  } catch (IOException e) {
    reporter.warning("can't read privte Key file: " + keyFileName);
  reporter.warning("\nUser private key is not set, generating new one.");
  reporter.message("new private key has been generated");
  privateKey = new PrivateKey(2048);
    reporter.verbose("creating new keys directory: " + keysDir.toString());
    final Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwx------");
    final FileAttribute<Set<PosixFilePermission>> ownerOnly = PosixFilePermissions.asFileAttribute(perms);
origin: UniversaBlockchain/universa

public void warning(String msg) {
  message(msg);
}
origin: UniversaBlockchain/universa

public ClientNetwork(String nodeUrl, BasicHttpClientSession session, boolean delayedStart) throws IOException {
  client = new Client(nodeUrl, CLIMain.getPrivateKey(), session, delayedStart);
  if (client == null)
    throw new IOException("failed to connect to to the universa network");
  reporter.verbose("Read Universa network configuration: " + client.size() + " nodes");
  reporter.message("Network version: " + client.getVersion());
}
origin: UniversaBlockchain/universa

private static void report(String message) {
  reporter.message(message);
}
origin: UniversaBlockchain/universa

private static void checkSj(Contract contract, Permission sj) {
  Binder params = sj.getParams();
  String fieldName = "state.data." + params.getStringOrThrow("field_name");
  reporter.verbose("splitjoins permission fond on field '" + fieldName + "'");
  StringBuilder outcome = new StringBuilder();
  List<Decimal> values = new ArrayList<>();
  reporter.verbose("operation is: "+ outcome.toString());
  Decimal saldo = values.stream().reduce(Decimal.ZERO, (a, b) -> a.add(b));
  if( saldo.compareTo(Decimal.ZERO) == 0 )
    reporter.verbose("Saldo looks good (zero)");
  else
    reporter.warning("Saldo is not zero: "+saldo);
origin: UniversaBlockchain/universa

private static Reporter callMain(String... args) throws Exception {
  output = ConsoleInterceptor.copyOut(() -> {
    String[] argsNew = new String[args.length+1];
    for(int i =0; i< args.length;i++) {
      argsNew[i] = args[i];
    }
    argsNew[args.length] = "--no-exit";
    CLIMain.main(argsNew);
    errors = CLIMain.getReporter().getErrors();
  });
  return CLIMain.getReporter();
}
net.sergeych.toolsReporter

Javadoc

Tool to report messages, errors, progress notifications the same way in console applications, GUI applications and services. Create instance and call #notice(String), #progress(String) and #error(String,String,String). Supports collecting and reporting collected data, #setQuiet(boolean) mode, #reportJson() and one level of verbisity: #setVerboseMode(boolean).

Most used methods

  • message
    message will be shown immediately or buffered and returned later in json mode.
  • getErrors
  • warning
  • <init>
  • clear
  • console
    print to console only, does notthing ing queit mode. To it to not to pollute json output with visual
  • error
    Report error. Unless in JSON mode, will be printed immediately. Errors are 3-field objects with stri
  • getMessage
  • isQuiet
    See #setQuiet(boolean)
  • isVerboseMode
  • newLine
    Outputs newline on the console only (does nothing in quiet more).
  • report
    Get collected report as a Binder object.
  • newLine,
  • report,
  • reportJson,
  • setQuiet,
  • setVerboseMode,
  • verbose

Popular in Java

  • Updating database using SQL prepared statement
  • scheduleAtFixedRate (Timer)
  • requestLocationUpdates (LocationManager)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top Sublime Text plugins
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