Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2008-2020, 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.sql.impl;
import com.hazelcast.internal.nio.Packet;
import com.hazelcast.internal.serialization.InternalSerializationService;
import com.hazelcast.sql.impl.exec.io.flowcontrol.FlowControlFactory;
import com.hazelcast.sql.impl.exec.io.flowcontrol.simple.SimpleFlowControlFactory;
import com.hazelcast.sql.impl.exec.root.BlockingRootResultConsumer;
import com.hazelcast.sql.impl.operation.QueryExecuteOperation;
import com.hazelcast.sql.impl.operation.QueryExecuteOperationFactory;
import com.hazelcast.sql.impl.operation.QueryOperationHandlerImpl;
import com.hazelcast.sql.impl.plan.Plan;
import com.hazelcast.sql.impl.plan.cache.CachedPlanInvalidationCallback;
import com.hazelcast.sql.impl.plan.cache.PlanCacheChecker;
import com.hazelcast.sql.impl.state.QueryClientStateRegistry;
import com.hazelcast.sql.impl.state.QueryState;
import com.hazelcast.sql.impl.state.QueryStateRegistry;
import com.hazelcast.sql.impl.state.QueryStateRegistryUpdater;
import com.hazelcast.sql.impl.type.converter.Converter;
import com.hazelcast.sql.impl.type.converter.Converters;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* Proxy for SQL service.
*/
public class SqlInternalService {
public static final String SERVICE_NAME = "hz:impl:sqlService";
/** Memory assigned to a single edge mailbox. Will be reworked to dynamic mode when memory manager is implemented. */
private static final long MEMORY_PER_EDGE_MAILBOX = 512 * 1024;
/** Default flow control factory. */
private static final FlowControlFactory FLOW_CONTROL_FACTORY = SimpleFlowControlFactory.INSTANCE;
/** Node service provider. */
private final NodeServiceProvider nodeServiceProvider;
/** Registry for running queries. */
private final QueryStateRegistry stateRegistry;
/** Registry for client queries. */
private final QueryClientStateRegistry clientStateRegistry;
/** Operation manager. */
private final QueryOperationHandlerImpl operationHandler;
/** State registry updater. */
private final QueryStateRegistryUpdater stateRegistryUpdater;
public SqlInternalService(
String instanceName,
NodeServiceProvider nodeServiceProvider,
InternalSerializationService serializationService,
int operationThreadCount,
int fragmentThreadCount,
int outboxBatchSize,
long stateCheckFrequency,
PlanCacheChecker planCacheChecker
) {
this.nodeServiceProvider = nodeServiceProvider;
// Create state registries since they do not depend on anything.
stateRegistry = new QueryStateRegistry(nodeServiceProvider);
clientStateRegistry = new QueryClientStateRegistry();
// Operation handler depends on state registry.
operationHandler = new QueryOperationHandlerImpl(
instanceName,
nodeServiceProvider,
serializationService,
stateRegistry,
outboxBatchSize,
FLOW_CONTROL_FACTORY,
fragmentThreadCount,
operationThreadCount
);
// State checker depends on state registries and operation handler.
stateRegistryUpdater = new QueryStateRegistryUpdater(
instanceName,
nodeServiceProvider,
stateRegistry,
clientStateRegistry,
operationHandler,
planCacheChecker,
stateCheckFrequency
);
}
public void start() {
stateRegistryUpdater.start();
}
public void shutdown() {
stateRegistryUpdater.shutdown();
operationHandler.shutdown();
stateRegistry.shutdown();
clientStateRegistry.shutdown();
}
/**
* Internal query execution routine.
*
* @return Query state.
*/
public QueryState execute(
Plan plan,
List