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);
}
}
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();
}
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;
}
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;
}
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;
}
Aggregations