Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ public void testFullBackupConcurrency() throws IOException, InterruptedException
}

final Thread[] threads = new Thread[CONCURRENT_THREADS];

final Database importedDatabase = importDatabase();
try {
final Database importedDatabase = importDatabase();

final VertexType type = importedDatabase.getSchema().createVertexType("BackupTest", CONCURRENT_THREADS);

Expand All @@ -126,12 +127,17 @@ public int getBucketIdByRecord(Document record, boolean async) {
public void run() {
final AtomicInteger totalPerThread = new AtomicInteger();
for (int j = 0; j < 500; j++) {
importedDatabase.transaction(() -> {
for (int k = 0; k < 500; k++) {
MutableVertex v = importedDatabase.newVertex("BackupTest").set("thread", threadId).set("id", totalPerThread.getAndIncrement()).save();
Assertions.assertEquals(threadBucket.getId(), v.getIdentity().getBucketId());
importedDatabase.begin();
for (int k = 0; k < 500; k++) {
MutableVertex v = importedDatabase.newVertex("BackupTest").set("thread", threadId).set("id", totalPerThread.getAndIncrement()).save();
Assertions.assertEquals(threadBucket.getId(), v.getIdentity().getBucketId());

if (k + 1 % 100 == 0) {
importedDatabase.commit();
importedDatabase.begin();
}
});
}
importedDatabase.commit();
}

}
Expand Down Expand Up @@ -170,8 +176,11 @@ public void run() {
}
}

Assertions.assertTrue(DatabaseFactory.getActiveDatabaseInstances().isEmpty(), "Found active databases: " + DatabaseFactory.getActiveDatabaseInstances());
} finally {
importedDatabase.close();

Assertions.assertTrue(DatabaseFactory.getActiveDatabaseInstances().isEmpty(), "Found active databases: " + DatabaseFactory.getActiveDatabaseInstances());

for (int i = 0; i < CONCURRENT_THREADS; i++) {
new File(FILE + "_" + i).delete();
FileUtils.deleteRecursively(new File(DATABASE_PATH + "_restored_" + i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public void testImportOK() throws IOException {
Assertions.assertEquals("admin", security.getString("name"));
}
}
Assertions.assertTrue(DatabaseFactory.getActiveDatabaseInstances().isEmpty(), "Found active databases: " + DatabaseFactory.getActiveDatabaseInstances());
} finally {
Assertions.assertTrue(DatabaseFactory.getActiveDatabaseInstances().isEmpty(), "Found active databases: " + DatabaseFactory.getActiveDatabaseInstances());
FileUtils.deleteRecursively(databaseDirectory);
}
}
Expand Down
23 changes: 10 additions & 13 deletions network/src/main/java/com/arcadedb/remote/RemoteDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,16 @@ public ResultSet command(final String language, final String command, final Obje
public ResultSet query(final String language, final String command, final Object... args) {
Map<String, Object> params = mapArgs(args);

return (ResultSet) databaseCommand("query", language, command, params, false, new Callback() {
@Override
public Object call(final HttpURLConnection connection, final JSONObject response) {
final ResultSet resultSet = new InternalResultSet();

final JSONArray resultArray = response.getJSONArray("result");
for (int i = 0; i < resultArray.length(); ++i) {
final JSONObject result = resultArray.getJSONObject(i);
((InternalResultSet) resultSet).add(new ResultInternal(result.toMap()));
}
return (ResultSet) databaseCommand("query", language, command, params, false, (connection, response) -> {
final ResultSet resultSet = new InternalResultSet();

return resultSet;
final JSONArray resultArray = response.getJSONArray("result");
for (int i = 0; i < resultArray.length(); ++i) {
final JSONObject result = resultArray.getJSONObject(i);
((InternalResultSet) resultSet).add(new ResultInternal(result.toMap()));
}

return resultSet;
});
}

Expand Down Expand Up @@ -420,14 +417,14 @@ private Object httpCommand(final String extendedURL, final String operation, fin
} catch (NeedRetryException | DuplicatedKeyException | TransactionException | TimeoutException e) {
throw e;
} catch (Exception e) {
throw new RemoteException("Error on executing remote operation " + operation, e);
throw new RemoteException("Error on executing remote operation " + operation + " (cause: " + e.getMessage() + ")", e);
}
}

if (lastException instanceof RuntimeException)
throw (RuntimeException) lastException;

throw new RemoteException("Error on executing remote operation " + operation, lastException);
throw new RemoteException("Error on executing remote operation " + operation + " (retry=" + maxRetry + ")", lastException);
}

public int getApiVersion() {
Expand Down
14 changes: 0 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,7 @@
<configuration>
<excludes>
<exclude>**/*HASplitBrainIT.java</exclude>
<exclude>**/*ReplicationServerLeaderDownNoTransactionsToForwardIT.java</exclude>
<exclude>**/*ReplicationServerLeaderChanges3TimesIT.java</exclude>
<exclude>**/*ReplicationServerLeaderDownIT.java</exclude>
<exclude>**/*ReplicationServerQuorumMajority2ServersOutIT.java</exclude>
<exclude>**/*ReplicationServerQuorumAllIT.java</exclude>
<exclude>**/*ReplicationServerQuorumMajorityIT.java</exclude>
<exclude>**/*ReplicationServerQuorumNoneIT.java</exclude>
<exclude>**/*ReplicationServerReplicaHotResyncIT.java</exclude>
<exclude>**/*ReplicationServerReplicaRestartForceDbInstallIT.java</exclude>
<exclude>**/*ReplicationServerWriteAgainstReplicaIT.java</exclude>
<exclude>**/*ServerBackupDatabaseIT.java</exclude>
<exclude>**/*HTTP2ServersIT.java</exclude>
<exclude>**/*TwoServersIT.java</exclude>
<exclude>**/*FullBackupIT.java</exclude>
<exclude>**/*RemoteConsoleIT.java</exclude>
<exclude>**/ArcadeGraphProcessDebugTest.java</exclude>
<exclude>**/ArcadeGraphStructureDebugTest.java</exclude>
<exclude>${exclude.tests}</exclude>
Expand Down