All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.instance.NodeExtension Maven / Gradle / Ivy

There is a newer version: 5.0-BETA-1
Show newest version
/*
 * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hazelcast.instance;

import com.hazelcast.client.impl.protocol.MessageTaskFactory;
import com.hazelcast.internal.storage.DataRef;
import com.hazelcast.internal.storage.Storage;
import com.hazelcast.memory.MemoryStats;
import com.hazelcast.nio.IOService;
import com.hazelcast.nio.MemberSocketInterceptor;
import com.hazelcast.nio.serialization.SerializationService;
import com.hazelcast.nio.tcp.PacketReader;
import com.hazelcast.nio.tcp.PacketWriter;
import com.hazelcast.nio.tcp.SocketChannelWrapperFactory;
import com.hazelcast.nio.tcp.TcpIpConnection;
import com.hazelcast.security.SecurityContext;

/**
 * NodeExtension is a Node extension mechanism to be able to plug different implementations of
 * some modules, like; SerializationService, SocketChannelWrapperFactory etc.
 *
 */
public interface NodeExtension {

    /**
     * Called before node is started
     */
    void beforeStart(Node node);

    /**
     * Called to print node information during startup
     */
    void printNodeInfo(Node node);

    /**
     * Called after node is started
     */
    void afterStart(Node node);

    /**
     * Creates a SerializationService instance to be used by this Node.
     *
     * @return a SerializationService instance
     */
    SerializationService createSerializationService();

    /**
     * Returns SecurityContext for this Node if available, otherwise returns null.
     *
     * @return security context
     */
    SecurityContext getSecurityContext();

    /**
     * @deprecated
     */
    @Deprecated
    Storage getNativeDataStorage();

    /**
     * Creates a service which is an implementation of given type parameter.
     * @param type type of service
     * @return service implementation
     * @throws java.lang.IllegalArgumentException if type is not known
     */
     T createService(Class type);

    /**
     * Returns MemberSocketInterceptor for this Node if available,
     * otherwise returns null.
     *
     * @return MemberSocketInterceptor
     */
    MemberSocketInterceptor getMemberSocketInterceptor();

    /**
     * Returns SocketChannelWrapperFactory instance to be used by this Node.
     *
     * @return SocketChannelWrapperFactory
     */
    SocketChannelWrapperFactory getSocketChannelWrapperFactory();

    /**
     * Creates a PacketReader for given Connection instance.
     *
     * @param connection tcp-ip connection
     * @param ioService IOService
     *
     * @return packet reader
     */
    PacketReader createPacketReader(TcpIpConnection connection, IOService ioService);

    /**
     * Creates a PacketWriter for given Connection instance.
     *
     * @param connection tcp-ip connection
     * @param ioService IOService
     *
     * @return packet writer
     */
    PacketWriter createPacketWriter(TcpIpConnection connection, IOService ioService);

    /***
     * Creates factory method that creates server side client message handlers
     *
     * @param node node
     */
    MessageTaskFactory createMessageTaskFactory(Node node);

    /**
     * Called on thread start to inject/intercept extension specific logic,
     * like; registering thread in some service,
     * executing a special method before thread starts to do its own task.
     *
     * @param thread thread starting
     */
    void onThreadStart(Thread thread);

    /**
     * Called before a thread stops to clean/release injected by {@link #onThreadStart(Thread)}.
     *
     * @param thread thread stopping
     */
    void onThreadStop(Thread thread);

    /**
     * Returns MemoryStats of for the JVM and current HazelcastInstance.
     *
     * @return memory statistics
     */
    MemoryStats getMemoryStats();

    /**
     * Destroys NodeExtension. Called on Node.shutdown()
     */
    void destroy();

    /**
     * Called before a new node is joining to cluster,
     * executed if node is the master node before join event.
     * {@link com.hazelcast.cluster.impl.ClusterServiceImpl} calls this method,
     * when handleJoinRequest method is called. By this way, we can check the logic we want
     * by implementing this method. Implementation should throw required exception, with a valid
     * message which explains rejection reason.
     */
    void beforeJoin();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy