Search in sources :

Example 1 with OStorageRemote

use of com.orientechnologies.orient.client.remote.OStorageRemote in project orientdb by orientechnologies.

the class ORemoteImportTest method testImport.

@Test
public void testImport() throws UnsupportedEncodingException {
    ODatabaseDocumentInternal db = new ODatabaseDocumentTx("remote:localhost/" + ORemoteImportTest.class.getSimpleName());
    db.open("admin", "admin");
    try {
        String content = "{\"records\": [{\"@type\": \"d\", \"@rid\": \"#9:0\",\"@version\": 1,\"@class\": \"V\"}]}";
        OStorageRemote storage = (OStorageRemote) db.getStorage();
        final StringBuffer buff = new StringBuffer();
        storage.importDatabase("-merge=true", new ByteArrayInputStream(content.getBytes("UTF8")), "data.json", new OCommandOutputListener() {

            @Override
            public void onMessage(String iText) {
                buff.append(iText);
            }
        });
        assertTrue(buff.toString().contains("Database import completed"));
    } finally {
        db.close();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) OStorageRemote(com.orientechnologies.orient.client.remote.OStorageRemote) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OCommandOutputListener(com.orientechnologies.orient.core.command.OCommandOutputListener) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal) Test(org.junit.Test)

Example 2 with OStorageRemote

use of com.orientechnologies.orient.client.remote.OStorageRemote in project orientdb by orientechnologies.

the class OConsoleDatabaseApp method info.

@ConsoleCommand(aliases = { "status" }, description = "Display information about the database", onlineHelp = "Console-Command-Info")
public void info() {
    if (currentDatabaseName != null) {
        message("\nCurrent database: " + currentDatabaseName + " (url=" + currentDatabase.getURL() + ")");
        final OStorage stg = currentDatabase.getStorage();
        if (stg instanceof OStorageRemote) {
            listServers();
        }
        listProperties();
        listClusters(null);
        listClasses();
        listIndexes();
    }
}
Also used : OStorageRemote(com.orientechnologies.orient.client.remote.OStorageRemote) OStorage(com.orientechnologies.orient.core.storage.OStorage) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Aggregations

OStorageRemote (com.orientechnologies.orient.client.remote.OStorageRemote)2 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)1 OCommandOutputListener (com.orientechnologies.orient.core.command.OCommandOutputListener)1 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)1 OStorage (com.orientechnologies.orient.core.storage.OStorage)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Test (org.junit.Test)1