Search in sources :

Example 26 with OConfigurationException

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;
        }
    }
}
Also used : OServerConfiguration(com.orientechnologies.orient.server.config.OServerConfiguration) OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OConsoleReader(com.orientechnologies.common.console.OConsoleReader) ODefaultConsoleReader(com.orientechnologies.common.console.ODefaultConsoleReader) OServerParameterConfiguration(com.orientechnologies.orient.server.config.OServerParameterConfiguration) OServerHandlerConfiguration(com.orientechnologies.orient.server.config.OServerHandlerConfiguration) OIOException(com.orientechnologies.common.io.OIOException)

Example 27 with OConfigurationException

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]));
    }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException)

Example 28 with OConfigurationException

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;
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OSQLFilter(com.orientechnologies.orient.core.sql.filter.OSQLFilter) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 29 with OConfigurationException

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);
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OCommandContext(com.orientechnologies.orient.core.command.OCommandContext) IOException(java.io.IOException) File(java.io.File) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 30 with OConfigurationException

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);
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OTransformer(com.orientechnologies.orient.etl.transformer.OTransformer)

Aggregations

OConfigurationException (com.orientechnologies.orient.core.exception.OConfigurationException)43 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)16 IOException (java.io.IOException)12 OException (com.orientechnologies.common.exception.OException)9 File (java.io.File)8 OIOException (com.orientechnologies.common.io.OIOException)5 OServerParameterConfiguration (com.orientechnologies.orient.server.config.OServerParameterConfiguration)5 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)4 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)3 OSystemException (com.orientechnologies.common.exception.OSystemException)3 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)3 ORetryQueryException (com.orientechnologies.orient.core.exception.ORetryQueryException)3 OTransactionException (com.orientechnologies.orient.core.exception.OTransactionException)3 OSerializationException (com.orientechnologies.orient.core.exception.OSerializationException)2 ORecordId (com.orientechnologies.orient.core.id.ORecordId)2 OStorage (com.orientechnologies.orient.core.storage.OStorage)2 OETLProcessHaltedException (com.orientechnologies.orient.etl.OETLProcessHaltedException)2 OServerConfigurationManager (com.orientechnologies.orient.server.config.OServerConfigurationManager)2 OServerNetworkListener (com.orientechnologies.orient.server.network.OServerNetworkListener)2 KeyStore (java.security.KeyStore)2