Ejemplo n.º 1
0
 public ScriptedDbBootstrapper() {
   try {
     this.db = Groovyness.newInstance("setup_db");
   } catch (ScriptExecutionFailedException ex) {
     LOG.error(ex, ex);
   }
 }
Ejemplo n.º 2
0
 public static ModifyPropertyValueResponseType modifyProperty(ModifyPropertyValueType request)
     throws EucalyptusCloudException {
   ModifyPropertyValueResponseType reply = request.getReply();
   if (INTERNAL_OP.equals(request.getName())) {
     if (!Contexts.lookup().hasAdministrativePrivileges()) {
       throw new EucalyptusCloudException("You are not authorized to interact with this service.");
     }
     LOG.debug("Performing euca operation: \n" + request.getValue());
     try {
       reply.setName(INTERNAL_OP);
       reply.setValue("" + Groovyness.eval(request.getValue()));
       reply.setOldValue("executed successfully.");
     } catch (Exception ex) {
       LOG.error(ex, ex);
       reply.setName(INTERNAL_OP);
       reply.setOldValue("euca operation failed because of: " + ex.getMessage());
       reply.setValue(Exceptions.string(ex));
     }
   } else {
     try {
       ConfigurableProperty entry = PropertyDirectory.getPropertyEntry(request.getName());
       String oldValue = "********";
       if (!entry.getWidgetType().equals(ConfigurableFieldType.KEYVALUEHIDDEN)) {
         oldValue = entry.getValue();
       }
       reply.setOldValue(oldValue);
       Boolean reset = request.getReset();
       if (reset != null) {
         if (Boolean.TRUE.equals(reset)) {
           entry.setValue(entry.getDefaultValue());
         }
       } else {
         // if property is ReadOnly it should not be set by user
         if (!entry.getReadOnly()) {
           try {
             String inValue = request.getValue();
             entry.setValue((inValue == null) ? "" : inValue);
           } catch (Exception e) {
             entry.setValue(oldValue);
             Exceptions.findAndRethrow(e, EucalyptusCloudException.class);
             throw e;
           }
         }
       }
       reply.setValue(entry.getValue());
       reply.setName(request.getName());
     } catch (IllegalAccessException e) {
       throw new EucalyptusCloudException("Failed to set property: " + e.getMessage());
     } catch (EucalyptusCloudException e) {
       throw e;
     } catch (Throwable e) {
       throw new EucalyptusCloudException(e);
     }
   }
   return reply;
 }
Ejemplo n.º 3
0
    @Override
    public boolean load() throws Exception {
      Hosts.awaitDatabases();
      Locks.DISABLED.isLocked();
      Locks.PARTITIONED.isLocked();

      Groovyness.run("setup_dbpool.groovy");
      OrderedShutdown.registerShutdownHook(
          Empyrean.class,
          new Runnable() {

            @Override
            public void run() {
              try {
                for (String ctx : PersistenceContexts.list()) {
                  try {
                    DatabaseClusterMBean db = Databases.lookup(ctx, TimeUnit.SECONDS.toMillis(5));
                    for (String host : db.getinactiveDatabases()) {
                      Databases.disable(host);
                    }
                    for (String host : db.getactiveDatabases()) {
                      Databases.disable(host);
                    }
                  } catch (Exception ex) {
                    LOG.error(ex);
                  }
                }
              } catch (NoSuchElementException ex) {
                LOG.error(ex);
              }
            }
          });
      TimeUnit.SECONDS.sleep(INITIAL_DB_SYNC_RETRY_WAIT);
      if (!Hosts.isCoordinator() && Hosts.localHost().hasDatabase()) {
        while (!Databases.enable(Hosts.localHost())) {
          LOG.warn(
              LogUtil.subheader("Synchronization of the database failed: " + Hosts.localHost()));
          if (counter.decrementAndGet() == 0) {
            LOG.fatal("Restarting process to force re-synchronization.");
            System.exit(123);
          } else {
            LOG.warn(
                "Sleeping for " + INITIAL_DB_SYNC_RETRY_WAIT + " seconds before trying again.");
            TimeUnit.SECONDS.sleep(INITIAL_DB_SYNC_RETRY_WAIT);
          }
        }

        Locks.DISABLED.create();

        Hosts.UpdateEntry.INSTANCE.apply(Hosts.localHost());
        LOG.info(LogUtil.subheader("Database synchronization complete: " + Hosts.localHost()));
      }
      return true;
    }
Ejemplo n.º 4
0
 static {
   Groovyness.loadConfig("walrusprops.groovy");
 }