use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class ODistributedAbstractPlugin method assignNodeName.
protected void assignNodeName() {
// ORIENTDB_NODE_NAME ENV VARIABLE OR JVM SETTING
nodeName = OSystemVariableResolver.resolveVariable(NODE_NAME_ENV);
if (nodeName != null) {
nodeName = nodeName.trim();
if (nodeName.isEmpty())
nodeName = null;
}
if (nodeName == null) {
try {
// WAIT ANY LOG IS PRINTED
Thread.sleep(1000);
} catch (InterruptedException e) {
}
System.out.println();
System.out.println();
System.out.println(OAnsiCode.format("$ANSI{yellow +---------------------------------------------------------------+}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | WARNING: FIRST DISTRIBUTED RUN CONFIGURATION |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow +---------------------------------------------------------------+}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | This is the first time that the server is running as |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | distributed. Please type the name you want to assign to the |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | current server node. |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | To avoid this message set the environment variable or JVM |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow | setting ORIENTDB_NODE_NAME to the server node name to use. |}"));
System.out.println(OAnsiCode.format("$ANSI{yellow +---------------------------------------------------------------+}"));
System.out.print(OAnsiCode.format("\n$ANSI{yellow Node name [BLANK=auto generate it]: }"));
OConsoleReader reader = new ODefaultConsoleReader();
try {
nodeName = reader.readLine();
} catch (IOException e) {
}
if (nodeName != null) {
nodeName = nodeName.trim();
if (nodeName.isEmpty())
nodeName = null;
}
}
if (nodeName == null)
// GENERATE NODE NAME
this.nodeName = "node" + System.currentTimeMillis();
OLogManager.instance().warn(this, "Assigning distributed node name: %s", this.nodeName);
// SALVE THE NODE NAME IN CONFIGURATION
boolean found = false;
final OServerConfiguration cfg = serverInstance.getConfiguration();
for (OServerHandlerConfiguration h : cfg.handlers) {
if (h.clazz.equals(getClass().getName())) {
for (OServerParameterConfiguration p : h.parameters) {
if (p.name.equals("nodeName")) {
found = true;
p.value = this.nodeName;
break;
}
}
if (!found) {
h.parameters = OArrays.copyOf(h.parameters, h.parameters.length + 1);
h.parameters[h.parameters.length - 1] = new OServerParameterConfiguration("nodeName", this.nodeName);
}
try {
serverInstance.saveConfiguration();
} catch (IOException e) {
throw OException.wrapException(new OConfigurationException("Cannot save server configuration"), e);
}
break;
}
}
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class OProxyServer method setPorts.
public void setPorts(final String portsAsString) {
ports.clear();
final String[] pairs = portsAsString.split(",");
for (String pair : pairs) {
final String[] fromTo = pair.split("->");
if (fromTo.length != 2)
throw new OConfigurationException("Proxy server: port configuration is not valid. Format: portFrom->portTo");
ports.put(Integer.parseInt(fromTo[0]), Integer.parseInt(fromTo[1]));
}
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class OAbstractETLComponent method skip.
protected boolean skip(final Object input) {
final OSQLFilter ifFilter = getIfFilter();
if (ifFilter != null) {
final ODocument doc = input instanceof OIdentifiable ? (ODocument) ((OIdentifiable) input).getRecord() : null;
log(LOG_LEVELS.DEBUG, "Evaluating conditional expression if=%s...", ifFilter);
final Object result = ifFilter.evaluate(doc, null, context);
if (!(result instanceof Boolean))
throw new OConfigurationException("'if' expression in Transformer " + getName() + " returned '" + result + "' instead of boolean");
return !(Boolean) result;
}
return false;
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class OETLProcessor method parseConfigAndParameters.
public static OETLProcessor parseConfigAndParameters(String[] args) {
final OCommandContext context = createDefaultContext();
ODocument configuration = new ODocument().fromJSON("{}");
for (final String arg : args) {
if (arg.charAt(0) != '-') {
try {
final String config = OIOUtils.readFileAsString(new File(arg));
configuration.merge(new ODocument().fromJSON(config, "noMap"), true, true);
// configuration = ;
ODocument cfgGlobal = configuration.field("config");
if (cfgGlobal != null) {
for (String f : cfgGlobal.fieldNames()) {
context.setVariable(f, cfgGlobal.field(f));
}
}
} catch (IOException e) {
throw OException.wrapException(new OConfigurationException("Error on loading config file: " + arg), e);
}
}
}
// override with args passed by command line
for (final String arg : args) {
if (arg.charAt(0) == '-') {
final String[] parts = arg.substring(1).split("=");
context.setVariable(parts[0], parts[1]);
}
}
return new OETLProcessor().parse(configuration, context);
}
use of com.orientechnologies.orient.core.exception.OConfigurationException in project orientdb by orientechnologies.
the class OETLProcessor method analyzeFlow.
protected void analyzeFlow() {
if (extractor == null)
throw new OConfigurationException("extractor is null");
if (loader == null)
throw new OConfigurationException("loader is null");
OETLComponent lastComponent = extractor;
for (OTransformer t : transformers) {
checkTypeCompatibility(t, lastComponent);
lastComponent = t;
}
checkTypeCompatibility(loader, lastComponent);
}
Aggregations