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;
}
Aggregations