Search in sources :

Example 1 with ManagementCenterService

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);
    }
}
Also used : ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) StringUtil.bytesToString(com.hazelcast.util.StringUtil.bytesToString)

Example 2 with ManagementCenterService

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);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) AbstractLocalOperation(com.hazelcast.spi.impl.operationservice.AbstractLocalOperation) CALLER_RUNS(com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) HazelcastException(com.hazelcast.core.HazelcastException) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) ManagementCenterConfig(com.hazelcast.config.ManagementCenterConfig) ExceptionUtil.peel(com.hazelcast.internal.util.ExceptionUtil.peel) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) Future(java.util.concurrent.Future) ILogger(com.hazelcast.logging.ILogger) StringUtil.isNullOrEmpty(com.hazelcast.internal.util.StringUtil.isNullOrEmpty) AccessControlException(java.security.AccessControlException) ExceptionUtil.withTryCatch(com.hazelcast.internal.util.ExceptionUtil.withTryCatch) HazelcastException(com.hazelcast.core.HazelcastException) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) AccessControlException(java.security.AccessControlException) ILogger(com.hazelcast.logging.ILogger) ManagementCenterConfig(com.hazelcast.config.ManagementCenterConfig) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService)

Example 3 with ManagementCenterService

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();
}
Also used : JoinConfig(com.hazelcast.config.JoinConfig) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) Thread.currentThread(java.lang.Thread.currentThread)

Example 4 with ManagementCenterService

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;
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) ClientBwListDTO(com.hazelcast.internal.management.dto.ClientBwListDTO)

Example 5 with ManagementCenterService

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());
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ManagementCenterService(com.hazelcast.internal.management.ManagementCenterService) Event(com.hazelcast.internal.management.events.Event) WanConsistencyCheckIgnoredEvent(com.hazelcast.internal.management.events.WanConsistencyCheckIgnoredEvent) WanSyncIgnoredEvent(com.hazelcast.internal.management.events.WanSyncIgnoredEvent) WanConsistencyCheckIgnoredEvent(com.hazelcast.internal.management.events.WanConsistencyCheckIgnoredEvent) CountDownLatch(java.util.concurrent.CountDownLatch) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

ManagementCenterService (com.hazelcast.internal.management.ManagementCenterService)13 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 Test (org.junit.Test)7 Event (com.hazelcast.internal.management.events.Event)6 WanConsistencyCheckIgnoredEvent (com.hazelcast.internal.management.events.WanConsistencyCheckIgnoredEvent)6 WanSyncIgnoredEvent (com.hazelcast.internal.management.events.WanSyncIgnoredEvent)6 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)6 LinkedList (java.util.LinkedList)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 HTTPCommunicator (com.hazelcast.internal.ascii.HTTPCommunicator)3 JsonObject (com.hazelcast.internal.json.JsonObject)3 HazelcastException (com.hazelcast.core.HazelcastException)2 Config (com.hazelcast.config.Config)1 JoinConfig (com.hazelcast.config.JoinConfig)1 ManagementCenterConfig (com.hazelcast.config.ManagementCenterConfig)1 ClientBwListDTO (com.hazelcast.internal.management.dto.ClientBwListDTO)1 CALLER_RUNS (com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS)1 ExceptionUtil.peel (com.hazelcast.internal.util.ExceptionUtil.peel)1 ExceptionUtil.withTryCatch (com.hazelcast.internal.util.ExceptionUtil.withTryCatch)1