@Override public void putAll(Map<? extends KEY, ? extends T> m) { for (Entry<? extends KEY, ? extends T> entry : m.entrySet()) { try { put( entry.getKey(), entry.getValue() ); } catch (RuntimeException e) { err(e); } } }
err(e); runtimeException("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName() + " value: " + value + " cause: " + e.getMessage()); } catch (IllegalAccessException e) { err(e); runtimeException("Cannot access option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName()); } catch (Exception e) { err(e); runtimeException("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName() + " value: " + value + " cause: " + e.getMessage());
PropertiesUtils.overWriteProperties(props,languageSpecificProperties); } catch (IOException e) { err("Failure to load language specific properties: " + languagePropertiesFile + " for " + language);
PropertiesUtils.overWriteProperties(props,languageSpecificProperties); } catch (IOException e) { err("Failure to load language specific properties: " + languagePropertiesFile + " for " + language);
err(e); runtimeException("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName() + " value: " + value + " cause: " + e.getMessage()); } catch (IllegalAccessException e) { err(e); runtimeException("Cannot access option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName()); } catch (Exception e) { err(e); runtimeException("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName() + " value: " + value + " cause: " + e.getMessage());
new StanfordCoreNLP(props); } catch (Throwable ignored) { err("Could not pre-load annotators in server; encountered exception:"); ignored.printStackTrace();
err(e); runtimeException("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName() + " value: " + value + " cause: " + e.getMessage()); } catch (IllegalAccessException e) { err(e); runtimeException("Cannot access option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName()); } catch (Exception e) { err(e); runtimeException("Cannot assign option field: " + f.getDeclaringClass().getCanonicalName() + '.' + f.getName() + " value: " + value + " cause: " + e.getMessage());
/** * If we have a separate liveness port, start a server on a separate thread pool whose only * job is to watch for when the CoreNLP server becomes ready. * This will also immediately signal liveness. * * @param live The boolean to track when CoreNLP has initialized and the server is ready * to serve requests. */ private void livenessServer(AtomicBoolean live) { if (this.serverPort != this.statusPort) { try { // Create the server if (this.ssl) { server = addSSLContext(HttpsServer.create(new InetSocketAddress(statusPort), 0)); // 0 is the default 'backlog' } else { server = HttpServer.create(new InetSocketAddress(statusPort), 0); // 0 is the default 'backlog' } // Add the two status endpoints withAuth(server.createContext("/live", new LiveHandler()), Optional.empty()); withAuth(server.createContext("/ready", new ReadyHandler(live)), Optional.empty()); // Start the server server.start(); // Server started log("Liveness server started at " + server.getAddress()); } catch (IOException e) { err("Could not start liveness server. This will probably result in very bad things happening soon.", e); } } }
/** The head of the relation of this relation triple. */ @Override public CoreLabel relationHead() { if (relation.size() == 1) { return relation.get(0); } CoreLabel guess = null; CoreLabel newGuess = super.relationHead(); int iters = 0; // make sure we don't infinite loop... while (guess != newGuess && iters < 100) { guess = newGuess; iters += 1; for (SemanticGraphEdge edge : sourceTree.incomingEdgeIterable(new IndexedWord(guess))) { // find a node in the relation list which is a governor of the candidate root Optional<CoreLabel> governor = relation.stream().filter(x -> x.index() == edge.getGovernor().index()).findFirst(); // if we found one, this is the new root. The for loop continues if (governor.isPresent()) { newGuess = governor.get(); } } } // Return if (iters >= 100) { err("Likely cycle in relation tree"); } return guess; }
/** The head of the relation of this relation triple. */ @Override public CoreLabel relationHead() { if (relation.size() == 1) { return relation.get(0); } CoreLabel guess = null; CoreLabel newGuess = super.relationHead(); int iters = 0; // make sure we don't infinite loop... while (guess != newGuess && iters < 100) { guess = newGuess; iters += 1; for (SemanticGraphEdge edge : sourceTree.incomingEdgeIterable(new IndexedWord(guess))) { // find a node in the relation list which is a governor of the candidate root Optional<CoreLabel> governor = relation.stream().filter(x -> x.index() == edge.getGovernor().index()).findFirst(); // if we found one, this is the new root. The for loop continues if (governor.isPresent()) { newGuess = governor.get(); } } } // Return if (iters >= 100) { err("Likely cycle in relation tree"); } return guess; }
runtimeException("Multiple declarations of option " + name + ": " + name1 + " and " + name2); } else { err("Class is in classpath multiple times: " + canFill.get(name).getDeclaringClass().getCanonicalName()); err("Unrecognized option: " + key); continue; clazz = ClassLoader.getSystemClassLoader().loadClass(className); } catch (Exception e) { err("Could not set option: " + entry.getKey() + "; either the option is mistyped, not defined, or the class " + className + " does not exist."); target = clazz.getField(fieldName); } catch (Exception e) { err("Could not set option: " + entry.getKey() + "; no such field: " + fieldName + " in class: " + className); fillField(class2object.get(target.getDeclaringClass()), target, value); } else { err("Could not set option: " + entry.getKey() + "; no such field: " + fieldName + " in class: " + className); Pair<Boolean, Boolean> mark = entry.getValue(); if (mark.first && !mark.second) { err("Missing required option: " + interner.get(key) + " <in class: " + canFill.get(key).getDeclaringClass() + '>'); required.put(key, Pair.makePair(true, true)); //don't duplicate error messages good = false;
} catch (IOException e) { log("ERROR: failed to save model to path: " + modelPath.get().getPath()); err(e);
new StanfordCoreNLP(props); } catch (Throwable ignored) { err("Could not pre-load annotators in server; encountered exception:"); ignored.printStackTrace();
err(e); throw throwSafe(e); } finally {
/** * If we have a separate liveness port, start a server on a separate thread pool whose only * job is to watch for when the CoreNLP server becomes ready. * This will also immediately signal liveness. * * @param live The boolean to track when CoreNLP has initialized and the server is ready * to serve requests. */ private void livenessServer(AtomicBoolean live) { if (this.serverPort != this.statusPort) { try { // Create the server if (this.ssl) { server = addSSLContext(HttpsServer.create(new InetSocketAddress(statusPort), 0)); // 0 is the default 'backlog' } else { server = HttpServer.create(new InetSocketAddress(statusPort), 0); // 0 is the default 'backlog' } // Add the two status endpoints withAuth(server.createContext("/live", new LiveHandler()), Optional.empty()); withAuth(server.createContext("/ready", new ReadyHandler(live)), Optional.empty()); // Start the server server.start(); // Server started log("Liveness server started at " + server.getAddress()); } catch (IOException e) { err("Could not start liveness server. This will probably result in very bad things happening soon.", e); } } }
@Override public boolean hasNext() { // Still have elements in this block if (elements.hasNext()) return true; // Still have files to traverse elements = null; while (index < files.length && elements == null) { try { elements = readBlock(files[index]).iterator(); } catch (OutOfMemoryError e) { warn("FileBackedCache", "Caught out of memory error (clearing cache): " + e.getMessage()); FileBackedCache.this.clear(); //noinspection EmptyCatchBlock try { Thread.sleep(1000); } catch (InterruptedException e2) { throw new RuntimeInterruptedException(e2); } elements = readBlock(files[index]).iterator(); } catch (RuntimeException e) { err(e); } index += 1; } // No more elements return elements != null && hasNext(); } @Override
/** The head of the relation of this relation triple. */ @Override public CoreLabel relationHead() { if (relation.size() == 1) { return relation.get(0); } CoreLabel guess = null; CoreLabel newGuess = super.relationHead(); int iters = 0; // make sure we don't infinite loop... while (guess != newGuess && iters < 100) { guess = newGuess; iters += 1; for (SemanticGraphEdge edge : sourceTree.incomingEdgeIterable(new IndexedWord(guess))) { // find a node in the relation list which is a governor of the candidate root Optional<CoreLabel> governor = relation.stream().filter(x -> x.index() == edge.getGovernor().index()).findFirst(); // if we found one, this is the new root. The for loop continues if (governor.isPresent()) { newGuess = governor.get(); } } } // Return if (iters >= 100) { err("Likely cycle in relation tree"); } return guess; }
/** Reads the block specified by the key in its entirety */ private Collection<Pair<KEY, T>> readBlock(Object key) { try { return readBlock(hash2file(key.hashCode(), true)); } catch (IOException e) { err("Could not read file: " + cacheDir.getPath() + File.separator + fileRoot(key.hashCode())); throw throwSafe(e); } }