use of com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin in project orientdb by orientechnologies.
the class OCommandExecutorSQLHAStatus method execute.
/**
* Execute the command.
*/
public Object execute(final Map<Object, Object> iArgs) {
final ODatabaseDocumentInternal database = getDatabase();
database.checkSecurity(ORule.ResourceGeneric.SERVER, "status", ORole.PERMISSION_READ);
final String dbUrl = database.getURL();
final String path = dbUrl.substring(dbUrl.indexOf(":") + 1);
final OServer serverInstance = OServer.getInstanceByPath(path);
final OHazelcastPlugin dManager = (OHazelcastPlugin) serverInstance.getDistributedManager();
if (dManager == null || !dManager.isEnabled())
throw new OCommandExecutionException("OrientDB is not started in distributed mode");
final String databaseName = database.getName();
final ODistributedConfiguration cfg = dManager.getDatabaseConfiguration(databaseName);
if (parsedStatement.outputText) {
final StringBuilder output = new StringBuilder();
if (parsedStatement.servers)
output.append(ODistributedOutput.formatServerStatus(dManager, dManager.getClusterConfiguration()));
if (parsedStatement.db)
output.append(ODistributedOutput.formatClusterTable(dManager, databaseName, cfg, dManager.getAvailableNodes(databaseName)));
if (parsedStatement.latency)
output.append(ODistributedOutput.formatLatency(dManager, dManager.getClusterConfiguration()));
if (parsedStatement.messages)
output.append(ODistributedOutput.formatMessages(dManager, dManager.getClusterConfiguration()));
return output.toString();
}
final ODocument output = new ODocument();
if (parsedStatement.servers)
output.field("servers", dManager.getClusterConfiguration(), OType.EMBEDDED);
if (parsedStatement.db)
output.field("database", cfg.getDocument(), OType.EMBEDDED);
return output;
}
use of com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin in project orientdb by orientechnologies.
the class OCommandExecutorSQLHASyncDatabase method execute.
/**
* Execute the SYNC DATABASE.
*/
public Object execute(final Map<Object, Object> iArgs) {
final ODatabaseDocumentInternal database = getDatabase();
database.checkSecurity(ORule.ResourceGeneric.DATABASE, "sync", ORole.PERMISSION_UPDATE);
final OStorage stg = database.getStorage();
if (!(stg instanceof ODistributedStorage))
throw new ODistributedException("SYNC DATABASE command cannot be executed against a non distributed server");
final ODistributedStorage dStg = (ODistributedStorage) stg;
final OHazelcastPlugin dManager = (OHazelcastPlugin) dStg.getDistributedManager();
if (dManager == null || !dManager.isEnabled())
throw new OCommandExecutionException("OrientDB is not started in distributed mode");
final String databaseName = database.getName();
return dManager.installDatabase(true, databaseName, false, OGlobalConfiguration.DISTRIBUTED_BACKUP_TRY_INCREMENTAL_FIRST.getValueAsBoolean());
}
use of com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin in project orientdb by orientechnologies.
the class ServerRun method terminateServer.
public void terminateServer() {
if (server != null) {
try {
HazelcastInstance hz = ((OHazelcastPlugin) server.getDistributedManager()).getHazelcastInstance();
final Node node = getHazelcastNode(hz);
node.getConnectionManager().shutdown();
node.shutdown(true);
hz.getLifecycleService().terminate();
} catch (Exception e) {
// IGNORE IT
}
try {
server.shutdown();
} catch (Exception e) {
// IGNORE IT
}
}
closeStorages();
}
use of com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin in project orientdb by orientechnologies.
the class OCommandExecutorSQLHARemoveServer method execute.
/**
* Execute the command.
*/
public Object execute(final Map<Object, Object> iArgs) {
final ODatabaseDocumentInternal database = getDatabase();
database.checkSecurity(ORule.ResourceGeneric.SERVER, "remove", ORole.PERMISSION_EXECUTE);
final String dbUrl = database.getURL();
final String path = dbUrl.substring(dbUrl.indexOf(":") + 1);
final OServer serverInstance = OServer.getInstanceByPath(path);
final OHazelcastPlugin dManager = (OHazelcastPlugin) serverInstance.getDistributedManager();
if (dManager == null || !dManager.isEnabled())
throw new OCommandExecutionException("OrientDB is not started in distributed mode");
final String databaseName = database.getName();
return dManager.removeNodeFromConfiguration(parsedStatement.serverName.getStringValue(), databaseName, false, true);
}
use of com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin in project orientdb by orientechnologies.
the class OCommandExecutorSQLHASyncCluster method execute.
/**
* Execute the SYNC CLUSTER.
*/
public Object execute(final Map<Object, Object> iArgs) {
final ODatabaseDocumentInternal database = getDatabase();
database.checkSecurity(ORule.ResourceGeneric.CLUSTER, "sync", ORole.PERMISSION_UPDATE);
final String dbUrl = database.getURL();
final String path = dbUrl.substring(dbUrl.indexOf(":") + 1);
final OServer serverInstance = OServer.getInstanceByPath(path);
final OHazelcastPlugin dManager = (OHazelcastPlugin) serverInstance.getDistributedManager();
if (dManager == null || !dManager.isEnabled())
throw new OCommandExecutionException("OrientDB is not started in distributed mode");
final String databaseName = database.getName();
try {
if (this.parsedStatement.modeFull) {
return replaceCluster(dManager, database, serverInstance, databaseName, this.parsedStatement.clusterName.getStringValue());
}
// else {
// int merged = 0;
// return String.format("Merged %d records", merged);
// }
} catch (Exception e) {
throw OException.wrapException(new OCommandExecutionException("Cannot execute synchronization of cluster"), e);
}
return "Mode not supported";
}
Aggregations