use of org.apache.qpid.server.model.StateTransition in project qpid-broker-j by apache.
the class PrincipalDatabaseAuthenticationManager method activate.
@Override
@StateTransition(currentState = { State.UNINITIALIZED, State.ERRORED }, desiredState = State.ACTIVE)
public ListenableFuture<Void> activate() {
final SettableFuture<Void> returnVal = SettableFuture.create();
final List<Principal> users = _principalDatabase == null ? Collections.<Principal>emptyList() : _principalDatabase.getUsers();
_userMap.clear();
if (!users.isEmpty()) {
for (final Principal user : users) {
final PrincipalAdapter principalAdapter = new PrincipalAdapter(user);
principalAdapter.registerWithParents();
principalAdapter.openAsync().addListener(new Runnable() {
@Override
public void run() {
_userMap.put(user, principalAdapter);
if (_userMap.size() == users.size()) {
setState(State.ACTIVE);
returnVal.set(null);
}
}
}, getTaskExecutor());
}
return returnVal;
} else {
setState(State.ACTIVE);
return Futures.immediateFuture(null);
}
}
use of org.apache.qpid.server.model.StateTransition in project qpid-broker-j by apache.
the class HttpManagement method doStart.
@StateTransition(currentState = { State.UNINITIALIZED, State.ERRORED }, desiredState = State.ACTIVE)
@SuppressWarnings("unused")
private ListenableFuture<Void> doStart() {
Collection<HttpPort<?>> httpPorts = getEligibleHttpPorts(getBroker().getPorts());
if (httpPorts.isEmpty()) {
LOGGER.warn("HttpManagement plugin is configured but no suitable HTTP ports are available.");
} else {
getBroker().getEventLogger().message(ManagementConsoleMessages.STARTUP(OPERATIONAL_LOGGING_NAME));
_server = createServer(httpPorts);
try {
_server.start();
logOperationalListenMessages();
} catch (PortBindFailureException e) {
getBroker().getEventLogger().message(PortMessages.BIND_FAILED("HTTP", e.getAddress().getPort()));
throw e;
} catch (Exception e) {
throw new ServerScopedRuntimeException("Failed to start HTTP management on ports : " + httpPorts, e);
}
getBroker().getEventLogger().message(ManagementConsoleMessages.READY(OPERATIONAL_LOGGING_NAME));
}
setState(State.ACTIVE);
return Futures.immediateFuture(null);
}
use of org.apache.qpid.server.model.StateTransition in project qpid-broker-j by apache.
the class ManagementModeStoreHandlerTest method createManagementModeStoreHandler.
private ManagementModeStoreHandler createManagementModeStoreHandler() {
_systemConfig.close();
Map<String, Object> attributes = new HashMap<>(_systemConfigAttributes);
attributes.put(ConfiguredObject.DESIRED_STATE, State.QUIESCED);
attributes.remove(ConfiguredObject.TYPE);
_systemConfig = new AbstractSystemConfig(_taskExecutor, mock(EventLogger.class), mock(Principal.class), attributes) {
@Override
protected void onOpen() {
}
@Override
protected DurableConfigurationStore createStoreObject() {
return _store;
}
@Override
protected ListenableFuture<Void> onClose() {
return Futures.immediateFuture(null);
}
@Override
@StateTransition(currentState = State.UNINITIALIZED, desiredState = State.QUIESCED)
protected ListenableFuture<Void> startQuiesced() {
return Futures.immediateFuture(null);
}
};
_systemConfig.open();
return new ManagementModeStoreHandler(_store, _systemConfig);
}
Aggregations