Search in sources :

Example 1 with ServerConfig

use of com.github.ambry.config.ServerConfig in project ambry by linkedin.

the class AmbryServer method startup.

public void startup() throws InstantiationException {
    try {
        logger.info("starting");
        clusterMap = clusterAgentsFactory.getClusterMap();
        logger.info("Initialized clusterMap");
        clusterParticipant = clusterAgentsFactory.getClusterParticipant();
        logger.info("Setting up JMX.");
        long startTime = SystemTime.getInstance().milliseconds();
        registry = clusterMap.getMetricRegistry();
        this.metrics = new ServerMetrics(registry);
        reporter = JmxReporter.forRegistry(registry).build();
        reporter.start();
        logger.info("creating configs");
        NetworkConfig networkConfig = new NetworkConfig(properties);
        StoreConfig storeConfig = new StoreConfig(properties);
        DiskManagerConfig diskManagerConfig = new DiskManagerConfig(properties);
        ServerConfig serverConfig = new ServerConfig(properties);
        ReplicationConfig replicationConfig = new ReplicationConfig(properties);
        ConnectionPoolConfig connectionPoolConfig = new ConnectionPoolConfig(properties);
        SSLConfig sslConfig = new SSLConfig(properties);
        ClusterMapConfig clusterMapConfig = new ClusterMapConfig(properties);
        StatsManagerConfig statsConfig = new StatsManagerConfig(properties);
        // verify the configs
        properties.verify();
        scheduler = Utils.newScheduler(serverConfig.serverSchedulerNumOfthreads, false);
        logger.info("check if node exist in clustermap host {} port {}", networkConfig.hostName, networkConfig.port);
        DataNodeId nodeId = clusterMap.getDataNodeId(networkConfig.hostName, networkConfig.port);
        if (nodeId == null) {
            throw new IllegalArgumentException("The node " + networkConfig.hostName + ":" + networkConfig.port + "is not present in the clustermap. Failing to start the datanode");
        }
        StoreKeyFactory storeKeyFactory = Utils.getObj(storeConfig.storeKeyFactory, clusterMap);
        FindTokenFactory findTokenFactory = Utils.getObj(replicationConfig.replicationTokenFactory, storeKeyFactory);
        storageManager = new StorageManager(storeConfig, diskManagerConfig, scheduler, registry, clusterMap.getReplicaIds(nodeId), storeKeyFactory, new BlobStoreRecovery(), new BlobStoreHardDelete(), new WriteStatusDelegate(clusterParticipant), time);
        storageManager.start();
        connectionPool = new BlockingChannelConnectionPool(connectionPoolConfig, sslConfig, clusterMapConfig, registry);
        connectionPool.start();
        replicationManager = new ReplicationManager(replicationConfig, clusterMapConfig, storeConfig, storageManager, storeKeyFactory, clusterMap, scheduler, nodeId, connectionPool, registry, notificationSystem);
        replicationManager.start();
        ArrayList<Port> ports = new ArrayList<Port>();
        ports.add(new Port(networkConfig.port, PortType.PLAINTEXT));
        if (nodeId.hasSSLPort()) {
            ports.add(new Port(nodeId.getSSLPort(), PortType.SSL));
        }
        networkServer = new SocketServer(networkConfig, sslConfig, registry, ports);
        requests = new AmbryRequests(storageManager, networkServer.getRequestResponseChannel(), clusterMap, nodeId, registry, findTokenFactory, notificationSystem, replicationManager, storeKeyFactory);
        requestHandlerPool = new RequestHandlerPool(serverConfig.serverRequestHandlerNumOfThreads, networkServer.getRequestResponseChannel(), requests);
        networkServer.start();
        logger.info("Creating StatsManager to publish stats");
        List<PartitionId> partitionIds = new ArrayList<>();
        for (ReplicaId replicaId : clusterMap.getReplicaIds(nodeId)) {
            partitionIds.add(replicaId.getPartitionId());
        }
        statsManager = new StatsManager(storageManager, partitionIds, registry, statsConfig, time);
        if (serverConfig.serverStatsPublishLocalEnabled) {
            statsManager.start();
        }
        List<AmbryHealthReport> ambryHealthReports = new ArrayList<>();
        if (serverConfig.serverStatsPublishHealthReportEnabled) {
            ambryHealthReports.add(new QuotaHealthReport(statsManager, serverConfig.serverQuotaStatsAggregateIntervalInMinutes));
        }
        clusterParticipant.initialize(networkConfig.hostName, networkConfig.port, ambryHealthReports);
        logger.info("started");
        long processingTime = SystemTime.getInstance().milliseconds() - startTime;
        metrics.serverStartTimeInMs.update(processingTime);
        logger.info("Server startup time in Ms " + processingTime);
    } catch (Exception e) {
        logger.error("Error during startup", e);
        throw new InstantiationException("failure during startup " + e);
    }
}
Also used : DiskManagerConfig(com.github.ambry.config.DiskManagerConfig) ConnectionPoolConfig(com.github.ambry.config.ConnectionPoolConfig) Port(com.github.ambry.network.Port) StorageManager(com.github.ambry.store.StorageManager) ArrayList(java.util.ArrayList) ServerConfig(com.github.ambry.config.ServerConfig) StoreKeyFactory(com.github.ambry.store.StoreKeyFactory) WriteStatusDelegate(com.github.ambry.clustermap.WriteStatusDelegate) SSLConfig(com.github.ambry.config.SSLConfig) ReplicationManager(com.github.ambry.replication.ReplicationManager) StatsManagerConfig(com.github.ambry.config.StatsManagerConfig) ReplicationConfig(com.github.ambry.config.ReplicationConfig) SocketServer(com.github.ambry.network.SocketServer) NetworkConfig(com.github.ambry.config.NetworkConfig) BlobStoreHardDelete(com.github.ambry.messageformat.BlobStoreHardDelete) PartitionId(com.github.ambry.clustermap.PartitionId) FindTokenFactory(com.github.ambry.store.FindTokenFactory) ClusterMapConfig(com.github.ambry.config.ClusterMapConfig) BlockingChannelConnectionPool(com.github.ambry.network.BlockingChannelConnectionPool) ReplicaId(com.github.ambry.clustermap.ReplicaId) IOException(java.io.IOException) BlobStoreRecovery(com.github.ambry.messageformat.BlobStoreRecovery) StoreConfig(com.github.ambry.config.StoreConfig) DataNodeId(com.github.ambry.clustermap.DataNodeId)

Aggregations

DataNodeId (com.github.ambry.clustermap.DataNodeId)1 PartitionId (com.github.ambry.clustermap.PartitionId)1 ReplicaId (com.github.ambry.clustermap.ReplicaId)1 WriteStatusDelegate (com.github.ambry.clustermap.WriteStatusDelegate)1 ClusterMapConfig (com.github.ambry.config.ClusterMapConfig)1 ConnectionPoolConfig (com.github.ambry.config.ConnectionPoolConfig)1 DiskManagerConfig (com.github.ambry.config.DiskManagerConfig)1 NetworkConfig (com.github.ambry.config.NetworkConfig)1 ReplicationConfig (com.github.ambry.config.ReplicationConfig)1 SSLConfig (com.github.ambry.config.SSLConfig)1 ServerConfig (com.github.ambry.config.ServerConfig)1 StatsManagerConfig (com.github.ambry.config.StatsManagerConfig)1 StoreConfig (com.github.ambry.config.StoreConfig)1 BlobStoreHardDelete (com.github.ambry.messageformat.BlobStoreHardDelete)1 BlobStoreRecovery (com.github.ambry.messageformat.BlobStoreRecovery)1 BlockingChannelConnectionPool (com.github.ambry.network.BlockingChannelConnectionPool)1 Port (com.github.ambry.network.Port)1 SocketServer (com.github.ambry.network.SocketServer)1 ReplicationManager (com.github.ambry.replication.ReplicationManager)1 FindTokenFactory (com.github.ambry.store.FindTokenFactory)1