Search in sources :

Example 1 with OServerNetworkListener

use of com.orientechnologies.orient.server.network.OServerNetworkListener in project orientdb by orientechnologies.

the class OServerPluginManager method registerStaticDirectory.

protected void registerStaticDirectory(final OServerPluginInfo iPluginData) {
    Object pluginWWW = iPluginData.getParameter("www");
    if (pluginWWW == null)
        pluginWWW = iPluginData.getName();
    final OServerNetworkListener httpListener = server.getListenerByProtocol(ONetworkProtocolHttpAbstract.class);
    if (httpListener == null)
        throw new OConfigurationException("HTTP listener not registered while installing Static Content command");
    final OServerCommandGetStaticContent command = (OServerCommandGetStaticContent) httpListener.getCommand(OServerCommandGetStaticContent.class);
    if (command != null) {
        final URL wwwURL = iPluginData.getClassLoader().findResource("www/");
        final OCallable<Object, String> callback;
        if (wwwURL != null)
            callback = createStaticLinkCallback(iPluginData, wwwURL);
        else
            // LET TO THE COMMAND TO CONTROL IT
            callback = new OCallable<Object, String>() {

                @Override
                public Object call(final String iArgument) {
                    return iPluginData.getInstance().getContent(iArgument);
                }
            };
        command.registerVirtualFolder(pluginWWW.toString(), callback);
    }
}
Also used : OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) OCallable(com.orientechnologies.common.util.OCallable) OServerCommandGetStaticContent(com.orientechnologies.orient.server.network.protocol.http.command.get.OServerCommandGetStaticContent) OServerNetworkListener(com.orientechnologies.orient.server.network.OServerNetworkListener) URL(java.net.URL)

Example 2 with OServerNetworkListener

use of com.orientechnologies.orient.server.network.OServerNetworkListener in project orientdb by orientechnologies.

the class OGraphServerHandler method startup.

@Override
public void startup() {
    final OServerNetworkListener listener = server.getListenerByProtocol(ONetworkProtocolHttpAbstract.class);
    if (listener != null)
        listener.registerStatelessCommand(new OServerCommandPostCommandGraph());
    if (!enabled)
        return;
    OGremlinHelper.global().setMaxGraphPool(graphPoolMax).create();
}
Also used : OServerNetworkListener(com.orientechnologies.orient.server.network.OServerNetworkListener) OServerCommandPostCommandGraph(com.orientechnologies.orient.graph.server.command.OServerCommandPostCommandGraph)

Example 3 with OServerNetworkListener

use of com.orientechnologies.orient.server.network.OServerNetworkListener in project orientdb by orientechnologies.

the class OServer method activate.

@SuppressWarnings("unchecked")
public OServer activate() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    try {
        serverSecurity = new ODefaultServerSecurity(this, serverCfg);
        Orient.instance().setSecurity(serverSecurity);
        // Checks to see if the OrientDB System Database exists and creates it if not.
        // Make sure this happens after setSecurityFactory() is called.
        initSystemDatabase();
        for (OServerLifecycleListener l : lifecycleListeners) l.onBeforeActivate();
        final OServerConfiguration configuration = serverCfg.getConfiguration();
        tokenHandler = new OTokenHandlerImpl(this);
        if (configuration.network != null) {
            // REGISTER/CREATE SOCKET FACTORIES
            if (configuration.network.sockets != null) {
                for (OServerSocketFactoryConfiguration f : configuration.network.sockets) {
                    Class<? extends OServerSocketFactory> fClass = (Class<? extends OServerSocketFactory>) loadClass(f.implementation);
                    OServerSocketFactory factory = fClass.newInstance();
                    try {
                        factory.config(f.name, f.parameters);
                        networkSocketFactories.put(f.name, factory);
                    } catch (OConfigurationException e) {
                        OLogManager.instance().error(this, "Error creating socket factory", e);
                    }
                }
            }
            // REGISTER PROTOCOLS
            for (OServerNetworkProtocolConfiguration p : configuration.network.protocols) networkProtocols.put(p.name, (Class<? extends ONetworkProtocol>) loadClass(p.implementation));
            // STARTUP LISTENERS
            for (OServerNetworkListenerConfiguration l : configuration.network.listeners) networkListeners.add(new OServerNetworkListener(this, networkSocketFactories.get(l.socket), l.ipAddress, l.portRange, l.protocol, networkProtocols.get(l.protocol), l.parameters, l.commands));
        } else
            OLogManager.instance().warn(this, "Network configuration was not found");
        try {
            loadStorages();
            loadUsers();
            loadDatabases();
        } catch (IOException e) {
            final String message = "Error on reading server configuration";
            OLogManager.instance().error(this, message, e);
            throw OException.wrapException(new OConfigurationException(message), e);
        }
        registerPlugins();
        for (OServerLifecycleListener l : lifecycleListeners) l.onAfterActivate();
        running = true;
        String httpAddress = "localhost:2480";
        for (OServerNetworkListener listener : getNetworkListeners()) {
            if (listener.getProtocolType().getName().equals(ONetworkProtocolHttpDb.class.getName()))
                httpAddress = listener.getListeningAddress(true);
        }
        OLogManager.instance().info(this, "OrientDB Studio available at $ANSI{blue http://%s/studio/index.html}", httpAddress);
        OLogManager.instance().info(this, "$ANSI{green:italic OrientDB Server is active} v" + OConstants.getVersion() + ".");
    } catch (ClassNotFoundException e) {
        running = false;
        throw e;
    } catch (InstantiationException e) {
        running = false;
        throw e;
    } catch (IllegalAccessException e) {
        running = false;
        throw e;
    } catch (RuntimeException e) {
        running = false;
        throw e;
    } finally {
        startupLatch.countDown();
    }
    return this;
}
Also used : OServerSocketFactory(com.orientechnologies.orient.server.network.OServerSocketFactory) IOException(java.io.IOException) OTokenHandlerImpl(com.orientechnologies.orient.server.token.OTokenHandlerImpl) OConfigurationException(com.orientechnologies.orient.core.exception.OConfigurationException) ODefaultServerSecurity(com.orientechnologies.orient.server.security.ODefaultServerSecurity) ONetworkProtocol(com.orientechnologies.orient.server.network.protocol.ONetworkProtocol) OServerNetworkListener(com.orientechnologies.orient.server.network.OServerNetworkListener) ONetworkProtocolHttpDb(com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpDb)

Example 4 with OServerNetworkListener

use of com.orientechnologies.orient.server.network.OServerNetworkListener in project wicket-orientdb by OrienteerBAP.

the class OrientDbSettings method resolveOrientDBRestApiUrl.

/**
 * Resolve OrientDB REST API URL to be used for OrientDb REST bridge
 * @return OrientDB REST API URL
 */
public String resolveOrientDBRestApiUrl() {
    OrientDbWebApplication app = OrientDbWebApplication.get();
    OServer server = app.getServer();
    if (server != null) {
        OServerNetworkListener http = server.getListenerByProtocol(ONetworkProtocolHttpAbstract.class);
        if (http != null) {
            return "http://" + http.getListeningAddress(true);
        }
    }
    return null;
}
Also used : OServer(com.orientechnologies.orient.server.OServer) OServerNetworkListener(com.orientechnologies.orient.server.network.OServerNetworkListener)

Example 5 with OServerNetworkListener

use of com.orientechnologies.orient.server.network.OServerNetworkListener in project orientdb by orientechnologies.

the class ODistributedAbstractPlugin method getLocalNodeConfiguration.

@Override
public ODocument getLocalNodeConfiguration() {
    final ODocument nodeCfg = new ODocument();
    nodeCfg.setTrackingChanges(false);
    nodeCfg.field("id", nodeId);
    nodeCfg.field("uuid", nodeUuid);
    nodeCfg.field("name", nodeName);
    nodeCfg.field("publicAddress", getPublicAddress());
    nodeCfg.field("startedOn", startedOn);
    nodeCfg.field("status", getNodeStatus());
    nodeCfg.field("connections", serverInstance.getClientConnectionManager().getTotal());
    final List<Map<String, Object>> listeners = new ArrayList<Map<String, Object>>();
    nodeCfg.field("listeners", listeners, OType.EMBEDDEDLIST);
    for (OServerNetworkListener listener : serverInstance.getNetworkListeners()) {
        final Map<String, Object> listenerCfg = new HashMap<String, Object>();
        listeners.add(listenerCfg);
        listenerCfg.put("protocol", listener.getProtocolType().getSimpleName());
        listenerCfg.put("listen", listener.getListeningAddress(true));
    }
    // STORE THE TEMP USER/PASSWD USED FOR REPLICATION
    final OServerUserConfiguration user = serverInstance.getUser(REPLICATOR_USER);
    if (user != null)
        nodeCfg.field("user_replicator", serverInstance.getUser(REPLICATOR_USER).password);
    nodeCfg.field("databases", getManagedDatabases());
    final long maxMem = Runtime.getRuntime().maxMemory();
    final long totMem = Runtime.getRuntime().totalMemory();
    final long freeMem = Runtime.getRuntime().freeMemory();
    final long usedMem = totMem - freeMem;
    nodeCfg.field("usedMemory", usedMem);
    nodeCfg.field("freeMemory", freeMem);
    nodeCfg.field("maxMemory", maxMem);
    nodeCfg.field("latencies", getMessageService().getLatencies(), OType.EMBEDDED);
    nodeCfg.field("messages", getMessageService().getMessageStats(), OType.EMBEDDED);
    for (Iterator<ODatabaseLifecycleListener> it = Orient.instance().getDbLifecycleListeners(); it.hasNext(); ) {
        final ODatabaseLifecycleListener listener = it.next();
        if (listener != null)
            listener.onLocalNodeConfigurationRequest(nodeCfg);
    }
    return nodeCfg;
}
Also used : OServerUserConfiguration(com.orientechnologies.orient.server.config.OServerUserConfiguration) OServerNetworkListener(com.orientechnologies.orient.server.network.OServerNetworkListener) OClusterPositionMap(com.orientechnologies.orient.core.storage.impl.local.paginated.OClusterPositionMap) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

OServerNetworkListener (com.orientechnologies.orient.server.network.OServerNetworkListener)8 IOException (java.io.IOException)4 OException (com.orientechnologies.common.exception.OException)3 OConfigurationException (com.orientechnologies.orient.core.exception.OConfigurationException)3 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)3 RetryableHazelcastException (com.hazelcast.spi.exception.RetryableHazelcastException)2 OOfflineNodeException (com.orientechnologies.common.concur.OOfflineNodeException)2 OInterruptedException (com.orientechnologies.common.concur.lock.OInterruptedException)2 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2 FileNotFoundException (java.io.FileNotFoundException)2 OCallable (com.orientechnologies.common.util.OCallable)1 OCallableNoParamNoReturn (com.orientechnologies.common.util.OCallableNoParamNoReturn)1 OSignalHandler (com.orientechnologies.orient.core.OSignalHandler)1 OSecurityException (com.orientechnologies.orient.core.exception.OSecurityException)1 OStorageException (com.orientechnologies.orient.core.exception.OStorageException)1 OClusterPositionMap (com.orientechnologies.orient.core.storage.impl.local.paginated.OClusterPositionMap)1 OServerCommandPostCommandGraph (com.orientechnologies.orient.graph.server.command.OServerCommandPostCommandGraph)1 OServer (com.orientechnologies.orient.server.OServer)1 OServerUserConfiguration (com.orientechnologies.orient.server.config.OServerUserConfiguration)1 OServerSocketFactory (com.orientechnologies.orient.server.network.OServerSocketFactory)1