Search in sources :

Example 1 with EventException

use of org.apache.asterix.event.error.EventException in project asterixdb by apache.

the class AsterixEventServiceUtil method validateAsterixInstanceExists.

public static AsterixInstance validateAsterixInstanceExists(String name, State... permissibleStates) throws Exception {
    AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(name);
    if (instance == null) {
        throw new EventException("Asterix instance by name " + name + " does not exist.");
    }
    boolean valid = false;
    for (State state : permissibleStates) {
        if (state.equals(instance.getState())) {
            valid = true;
            break;
        }
    }
    if (!valid) {
        throw new EventException("Asterix instance by the name " + name + " is in " + instance.getState() + " state ");
    }
    return instance;
}
Also used : EventException(org.apache.asterix.event.error.EventException) State(org.apache.asterix.event.model.AsterixInstance.State) AsterixInstance(org.apache.asterix.event.model.AsterixInstance)

Aggregations

EventException (org.apache.asterix.event.error.EventException)1 AsterixInstance (org.apache.asterix.event.model.AsterixInstance)1 State (org.apache.asterix.event.model.AsterixInstance.State)1