use of com.hazelcast.internal.management.ManagementCenterService in project hazelcast by hazelcast.
the class HttpPostCommandProcessor method handleManagementCenterUrlChange.
private void handleManagementCenterUrlChange(HttpPostCommand command) throws UnsupportedEncodingException {
if (textCommandService.getNode().getProperties().getBoolean(GroupProperty.MC_URL_CHANGE_ENABLED)) {
byte[] res = HttpCommand.RES_204;
byte[] data = command.getData();
String[] strList = bytesToString(data).split("&");
String cluster = URLDecoder.decode(strList[0], "UTF-8");
String pass = URLDecoder.decode(strList[1], "UTF-8");
String url = URLDecoder.decode(strList[2], "UTF-8");
ManagementCenterService managementCenterService = textCommandService.getNode().getManagementCenterService();
if (managementCenterService != null) {
res = managementCenterService.clusterWideUpdateManagementCenterUrl(cluster, pass, url);
}
command.setResponse(res);
} else {
command.setResponse(HttpCommand.RES_503);
}
}
use of com.hazelcast.internal.management.ManagementCenterService in project hazelcast by hazelcast.
the class RunConsoleCommandOperation method run.
@Override
public void run() throws Exception {
final ManagementCenterService mcs = ((NodeEngineImpl) getNodeEngine()).getManagementCenterService();
if (mcs == null) {
sendResponse(new HazelcastException("ManagementCenterService is not initialized yet"));
return;
}
final ILogger logger = getNodeEngine().getLogger(getClass());
final ExecutionService executionService = getNodeEngine().getExecutionService();
Future<String> future = executionService.submit(ExecutionService.MC_EXECUTOR, () -> {
ManagementCenterConfig mcConfig = getNodeEngine().getConfig().getManagementCenterConfig();
if (!mcConfig.isConsoleEnabled()) {
throw new AccessControlException("Using Console is not allowed on this Hazelcast member.");
}
try {
final String ns = namespace;
String cmd = command;
if (!isNullOrEmpty(ns)) {
// set namespace as a part of the command
cmd = ns + "__" + cmd;
}
return mcs.runConsoleCommand(cmd);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw e;
}
});
executionService.asCompletableFuture(future).whenCompleteAsync(withTryCatch(logger, (output, error) -> sendResponse(error != null ? peel(error) : output)), CALLER_RUNS);
}
use of com.hazelcast.internal.management.ManagementCenterService in project hazelcast by hazelcast.
the class Node method start.
void start() {
nodeEngine.start();
initializeListeners(config);
hazelcastInstance.lifecycleService.fireLifecycleEvent(LifecycleState.STARTING);
clusterService.sendLocalMembershipEvent();
server.start();
JoinConfig join = getActiveMemberNetworkConfig(config).getJoin();
if (shouldUseMulticastJoiner(join)) {
final Thread multicastServiceThread = new Thread(multicastService, createThreadName(hazelcastInstance.getName(), "MulticastThread"));
multicastServiceThread.start();
}
if (properties.getBoolean(DISCOVERY_SPI_ENABLED) || isAnyAliasedConfigEnabled(join) || (join.isAutoDetectionEnabled() && !isEmptyDiscoveryStrategies())) {
discoveryService.start();
// Discover local metadata from environment and merge into member attributes
mergeEnvironmentProvidedMemberMetadata();
}
if (properties.getBoolean(SHUTDOWNHOOK_ENABLED)) {
logger.finest("Adding ShutdownHook");
Runtime.getRuntime().addShutdownHook(shutdownHookThread);
}
state = NodeState.ACTIVE;
nodeExtension.beforeJoin();
join();
int clusterSize = clusterService.getSize();
if (getActiveMemberNetworkConfig(config).isPortAutoIncrement() && address.getPort() >= getActiveMemberNetworkConfig(config).getPort() + clusterSize) {
logger.warning("Config seed port is " + getActiveMemberNetworkConfig(config).getPort() + " and cluster size is " + clusterSize + ". Some of the ports seem occupied!");
}
try {
managementCenterService = new ManagementCenterService(hazelcastInstance);
} catch (Exception e) {
logger.warning("ManagementCenterService could not be constructed!", e);
}
nodeExtension.afterStart();
nodeExtension.sendPhoneHome();
healthMonitor.start();
}
use of com.hazelcast.internal.management.ManagementCenterService in project hazelcast by hazelcast.
the class ApplyClientFilteringConfigMessageTask method call.
@Override
protected Object call() throws Exception {
ManagementCenterService mcs = nodeEngine.getManagementCenterService();
if (mcs == null) {
throw new HazelcastException("ManagementCenterService is not initialized yet");
}
ClientBwListDTO.Mode mode = ClientBwListDTO.Mode.getById(parameters.clientBwListMode);
if (mode == null) {
throw new IllegalArgumentException("Unexpected client B/W list mode = [" + parameters.clientBwListMode + "]");
}
mcs.applyMCConfig(parameters.eTag, new ClientBwListDTO(mode, parameters.clientBwListEntries));
return null;
}
use of com.hazelcast.internal.management.ManagementCenterService in project hazelcast by hazelcast.
the class WanOpenSourceAntiEntropyMcEventsTest method testConsistencyCheckAPI.
@Test
public void testConsistencyCheckAPI() {
HazelcastInstance hz = createHazelcastInstance();
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
WanReplicationService wanService = nodeEngine.getWanReplicationService();
ManagementCenterService mcService = nodeEngine.getManagementCenterService();
List<Event> events = new LinkedList<>();
CountDownLatch latch = new CountDownLatch(1);
mcService.setEventListener(event -> {
events.add(event);
latch.countDown();
});
assertThrows(UnsupportedOperationException.class, () -> wanService.consistencyCheck(WAN_REPLICATION_NAME, WAN_PUBLISHER_ID, MAP_NAME));
assertOpenEventually(latch);
Event event = events.get(0);
assertTrue(event instanceof WanConsistencyCheckIgnoredEvent);
WanConsistencyCheckIgnoredEvent checkIgnoredEvent = (WanConsistencyCheckIgnoredEvent) event;
assertNotNull(checkIgnoredEvent.getUuid());
assertEquals(MAP_NAME, checkIgnoredEvent.getMapName());
}
Aggregations