Esempio n. 1
0
  /**
   * Drops a database from a remote server instance.
   *
   * @param iDatabaseName The database name
   * @param storageType Storage type between "plocal" or "memory".
   * @return The instance itself. Useful to execute method in chain
   * @throws IOException
   */
  public synchronized OServerAdmin dropDatabase(
      final String iDatabaseName, final String storageType) throws IOException {

    boolean retry = true;
    while (retry) {
      retry =
          networkAdminOperation(
              new OStorageRemoteOperation<Boolean>() {
                @Override
                public Boolean execute(
                    final OChannelBinaryAsynchClient network, OStorageRemoteSession session)
                    throws IOException {
                  try {
                    try {
                      storage.beginRequest(
                          network, OChannelBinaryProtocol.REQUEST_DB_DROP, session);
                      network.writeString(iDatabaseName);
                      network.writeString(storageType);
                    } finally {
                      storage.endRequest(network);
                    }

                    storage.getResponse(network, session);
                    return false;
                  } catch (OModificationOperationProhibitedException oope) {
                    return handleDBFreeze();
                  }
                }
              },
              "Cannot delete the remote storage: " + storage.getName());
    }

    final Set<OStorage> underlyingStorages = new HashSet<OStorage>();

    for (OStorage s : Orient.instance().getStorages()) {
      if (s.getType().equals(storage.getType()) && s.getName().equals(storage.getName())) {
        underlyingStorages.add(s.getUnderlying());
      }
    }

    for (OStorage s : underlyingStorages) {
      s.close(true, true);
    }

    ODatabaseRecordThreadLocal.INSTANCE.remove();

    return this;
  }
Esempio n. 2
0
 public void checkEmbedded(final OStorage storage) {
   if (!(storage.getUnderlying() instanceof OAbstractPaginatedStorage))
     throw new OSchemaException(
         "'Internal' schema modification methods can be used only inside of embedded database");
 }