Remove the *.orig files lying in the repo.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/c5f5e282 Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/c5f5e282 Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/c5f5e282 Branch: refs/heads/master Commit: c5f5e282b20838d75f58f42f27403b18f15f9a22 Parents: 26fee8a Author: vkorukanti <[email protected]> Authored: Mon May 12 12:29:32 2014 -0700 Committer: Aditya Kishore <[email protected]> Committed: Mon May 12 21:33:31 2014 -0700 ---------------------------------------------------------------------- .../exec/expr/fn/impl/HashFunctions.java.orig | 252 ------------------- .../drill/exec/ops/QueryContext.java.orig | 135 ---------- .../apache/drill/exec/server/Drillbit.java.orig | 141 ----------- .../drill/exec/server/DrillbitContext.java.orig | 157 ------------ .../exec/store/StoragePluginRegistry.java.orig | 243 ------------------ 5 files changed, 928 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/c5f5e282/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/HashFunctions.java.orig ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/HashFunctions.java.orig b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/HashFunctions.java.orig deleted file mode 100644 index 7eeb730..0000000 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/HashFunctions.java.orig +++ /dev/null @@ -1,252 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.drill.exec.expr.fn.impl; - -import org.apache.drill.exec.expr.DrillSimpleFunc; -import org.apache.drill.exec.expr.annotations.FunctionTemplate; -import org.apache.drill.exec.expr.annotations.FunctionTemplate.FunctionScope; -import org.apache.drill.exec.expr.annotations.Output; -import org.apache.drill.exec.expr.annotations.Param; -import org.apache.drill.exec.expr.holders.*; -import org.apache.drill.exec.record.RecordBatch; - -public class HashFunctions { - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL ) - public static class NullableFloatHash implements DrillSimpleFunc { - - @Param NullableFloat4Holder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - if (in.isSet == 0) - out.value = 0; - else - out.value = com.google.common.hash.Hashing.murmur3_128().hashInt(Float.floatToIntBits(in.value)).asInt(); - } - } - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL ) - public static class FloatHash implements DrillSimpleFunc { - - @Param Float4Holder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - out.value = com.google.common.hash.Hashing.murmur3_128().hashInt(Float.floatToIntBits(in.value)).asInt(); - } - } - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL ) - public static class NullableDoubleHash implements DrillSimpleFunc { - - @Param NullableFloat8Holder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - if (in.isSet == 0) - out.value = 0; - else - out.value = com.google.common.hash.Hashing.murmur3_128().hashLong(Double.doubleToLongBits(in.value)).asInt(); - } - } - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL ) - public static class DoubleHash implements DrillSimpleFunc { - - @Param Float8Holder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - out.value = com.google.common.hash.Hashing.murmur3_128().hashLong(Double.doubleToLongBits(in.value)).asInt(); - } - } - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL ) - public static class NullableVarBinaryHash implements DrillSimpleFunc { - - @Param NullableVarBinaryHolder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - if (in.isSet == 0) - out.value = 0; - else - out.value = org.apache.drill.exec.expr.fn.impl.HashHelper.hash(in.buffer.nioBuffer(in.start, in.end - in.start), 0); - } - } - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL ) - public static class NullableVarCharHash implements DrillSimpleFunc { - - @Param NullableVarCharHolder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - if (in.isSet == 0) - out.value = 0; - else - out.value = org.apache.drill.exec.expr.fn.impl.HashHelper.hash(in.buffer.nioBuffer(in.start, in.end - in.start), 0); - } - } - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL ) - public static class NullableVar16CharHash implements DrillSimpleFunc { - - @Param NullableVar16CharHolder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - if (in.isSet == 0) - out.value = 0; - else - out.value = org.apache.drill.exec.expr.fn.impl.HashHelper.hash(in.buffer.nioBuffer(in.start, in.end - in.start), 0); - } - } - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL) - public static class NullableBigIntHash implements DrillSimpleFunc { - - @Param NullableBigIntHolder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - // TODO: implement hash function for other types - if (in.isSet == 0) - out.value = 0; - else - out.value = com.google.common.hash.Hashing.murmur3_128().hashLong(in.value).asInt(); - } - } - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL) - public static class NullableIntHash implements DrillSimpleFunc { - @Param NullableIntHolder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - // TODO: implement hash function for other types - if (in.isSet == 0) - out.value = 0; - else - out.value = com.google.common.hash.Hashing.murmur3_128().hashInt(in.value).asInt(); - } - } - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL) - public static class VarBinaryHash implements DrillSimpleFunc { - - @Param VarBinaryHolder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - out.value = org.apache.drill.exec.expr.fn.impl.HashHelper.hash(in.buffer.nioBuffer(in.start, in.end - in.start), 0); - } - } - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL) - public static class VarCharHash implements DrillSimpleFunc { - - @Param VarCharHolder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - out.value = org.apache.drill.exec.expr.fn.impl.HashHelper.hash(in.buffer.nioBuffer(in.start, in.end - in.start), 0); - } - } - -<<<<<<< HEAD - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL) - public static class Var16CharHash implements DrillSimpleFunc { - - @Param Var16CharHolder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - out.value = org.apache.drill.exec.expr.fn.impl.HashHelper.hash(in.buffer.nioBuffer(in.start, in.end - in.start), 0); - } - } - -======= ->>>>>>> 450e9e0... Support Complex Types - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL) - public static class HashBigInt implements DrillSimpleFunc { - - @Param BigIntHolder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - // TODO: implement hash function for other types - out.value = com.google.common.hash.Hashing.murmur3_128().hashLong(in.value).asInt(); - } - } - - @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL) - public static class IntHash implements DrillSimpleFunc { - @Param IntHolder in; - @Output IntHolder out; - - public void setup(RecordBatch incoming) { - } - - public void eval() { - // TODO: implement hash function for other types - out.value = com.google.common.hash.Hashing.murmur3_128().hashInt(in.value).asInt(); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/c5f5e282/exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java.orig ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java.orig b/exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java.orig deleted file mode 100644 index 4f050a6..0000000 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/ops/QueryContext.java.orig +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.drill.exec.ops; - -import java.util.Collection; - -import net.hydromatic.optiq.SchemaPlus; -import net.hydromatic.optiq.tools.Frameworks; - -import org.apache.drill.common.config.DrillConfig; -import org.apache.drill.common.exceptions.ExpressionParsingException; -import org.apache.drill.exec.cache.DistributedCache; -import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry; -import org.apache.drill.exec.planner.PhysicalPlanReader; -import org.apache.drill.exec.planner.physical.PlannerSettings; -import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; -import org.apache.drill.exec.proto.UserBitShared.QueryId; -import org.apache.drill.exec.rpc.control.WorkEventBus; -import org.apache.drill.exec.rpc.data.DataConnectionCreator; -import org.apache.drill.exec.rpc.user.UserSession; -import org.apache.drill.exec.server.DrillbitContext; -import org.apache.drill.exec.store.StoragePluginRegistry; - -public class QueryContext{ - static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(QueryContext.class); - - private final QueryId queryId; - private final DrillbitContext drillbitContext; - private final WorkEventBus workBus; - private UserSession session; - public final Multitimer<QuerySetup> timer; - private final PlannerSettings plannerSettings; - - public QueryContext(UserSession session, QueryId queryId, DrillbitContext drllbitContext) { - super(); - this.queryId = queryId; - this.drillbitContext = drllbitContext; - this.workBus = drllbitContext.getWorkBus(); - this.session = session; - this.timer = new Multitimer<>(QuerySetup.class); - this.plannerSettings = new PlannerSettings(); - } - - public PlannerSettings getPlannerSettings(){ - return plannerSettings; - } - - public UserSession getSession(){ - return session; - } - - public SchemaPlus getNewDefaultSchema(){ - SchemaPlus rootSchema = getRootSchema(); - SchemaPlus defaultSchema = session.getDefaultSchema(rootSchema); - if(defaultSchema == null){ - return rootSchema; - }else{ - return defaultSchema; - } - } - - public SchemaPlus getRootSchema(){ - SchemaPlus rootSchema = Frameworks.createRootSchema(); - drillbitContext.getSchemaFactory().registerSchemas(session.getUser(), rootSchema); - return rootSchema; - } - -<<<<<<< HEAD -======= - public Object getOptionValue(String name){ - return drillbitContext.getGlobalDrillOptions().getOption(name); - } - - public void setOptionValue(String name, String value) throws ExpressionParsingException { - drillbitContext.getGlobalDrillOptions().setOption(name, value); - } - ->>>>>>> Drill 381 - implementation of session and global options. - public DrillbitEndpoint getCurrentEndpoint(){ - return drillbitContext.getEndpoint(); - } - - public QueryId getQueryId() { - return queryId; - } - - public StoragePluginRegistry getStorage(){ - return drillbitContext.getStorage(); - } - - - public DistributedCache getCache(){ - return drillbitContext.getCache(); - } - - public Collection<DrillbitEndpoint> getActiveEndpoints(){ - return drillbitContext.getBits(); - } - - public PhysicalPlanReader getPlanReader(){ - return drillbitContext.getPlanReader(); - } - - public DataConnectionCreator getDataConnectionsPool(){ - return drillbitContext.getDataConnectionsPool(); - } - - public DrillConfig getConfig(){ - return drillbitContext.getConfig(); - } - - public WorkEventBus getWorkBus(){ - return workBus; - } - - public FunctionImplementationRegistry getFunctionRegistry(){ - return drillbitContext.getFunctionImplementationRegistry(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/c5f5e282/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java.orig ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java.orig b/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java.orig deleted file mode 100644 index 5e72717..0000000 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java.orig +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.drill.exec.server; - -import java.io.Closeable; - -import org.apache.drill.common.config.DrillConfig; -import org.apache.drill.exec.ExecConstants; -import org.apache.drill.exec.cache.DistributedCache; -import org.apache.drill.exec.cache.DistributedMultiMap; -import org.apache.drill.exec.cache.HazelCache; -import org.apache.drill.exec.coord.ClusterCoordinator; -import org.apache.drill.exec.coord.ClusterCoordinator.RegistrationHandle; -import org.apache.drill.exec.coord.ZKClusterCoordinator; -import org.apache.drill.exec.exception.DrillbitStartupException; -import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; -import org.apache.drill.exec.service.ServiceEngine; -import org.apache.drill.exec.work.WorkManager; - -import com.google.common.io.Closeables; - -/** - * Starts, tracks and stops all the required services for a Drillbit daemon to work. - */ -public class Drillbit implements Closeable{ - static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Drillbit.class); - - public static Drillbit start(StartupOptions options) throws DrillbitStartupException { - return start(DrillConfig.create(options.getConfigLocation())); - } - - public static Drillbit start(DrillConfig config) throws DrillbitStartupException { - Drillbit bit; - try { - logger.debug("Setting up Drillbit."); - bit = new Drillbit(config, null); - } catch (Exception ex) { - throw new DrillbitStartupException("Failure while initializing values in Drillbit.", ex); - } - try { - logger.debug("Starting Drillbit."); - bit.run(); - } catch (Exception e) { - throw new DrillbitStartupException("Failure during initial startup of Drillbit.", e); - } - return bit; - } - - public static void main(String[] cli) throws DrillbitStartupException { - StartupOptions options = StartupOptions.parse(cli); - start(options); - } - - final ClusterCoordinator coord; - final ServiceEngine engine; - final DistributedCache cache; - final WorkManager manager; - final BootStrapContext context; - - private volatile RegistrationHandle handle; - - public Drillbit(DrillConfig config, RemoteServiceSet serviceSet) throws Exception { - if(serviceSet != null){ - this.context = new BootStrapContext(config); - this.manager = new WorkManager(context); - this.coord = serviceSet.getCoordinator(); - this.engine = new ServiceEngine(manager.getControlMessageHandler(), manager.getUserWorker(), context, manager.getWorkBus(), manager.getDataHandler()); - this.cache = serviceSet.getCache(); - }else{ - Runtime.getRuntime().addShutdownHook(new ShutdownThread(config)); - this.context = new BootStrapContext(config); - this.manager = new WorkManager(context); - this.coord = new ZKClusterCoordinator(config); - this.engine = new ServiceEngine(manager.getControlMessageHandler(), manager.getUserWorker(), context, manager.getWorkBus(), manager.getDataHandler()); - this.cache = new HazelCache(config, context.getAllocator()); - } - } - - public void run() throws Exception { - coord.start(10000); - DrillbitEndpoint md = engine.start(); - cache.run(); -<<<<<<< HEAD - manager.getContext().getStorage().init(); -======= - manager.start(md, cache, engine.getController(), engine.getDataConnectionCreator(), coord); ->>>>>>> Drill 381 - implementation of session and global options. - handle = coord.register(md); - } - - public void close() { - if (coord != null) coord.unregister(handle); - - try { - Thread.sleep(context.getConfig().getInt(ExecConstants.ZK_REFRESH) * 2); - } catch (InterruptedException e) { - logger.warn("Interrupted while sleeping during coordination deregistration."); - } - - Closeables.closeQuietly(engine); - Closeables.closeQuietly(coord); - Closeables.closeQuietly(manager); - Closeables.closeQuietly(context); - logger.info("Shutdown completed."); - } - - private class ShutdownThread extends Thread { - ShutdownThread(DrillConfig config) { - this.setName("ShutdownHook"); - } - - @Override - public void run() { - logger.info("Received shutdown request."); - close(); - } - - } - public ClusterCoordinator getCoordinator(){ - return coord; - } - - public DrillbitContext getContext(){ - return this.manager.getContext(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/c5f5e282/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java.orig ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java.orig b/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java.orig deleted file mode 100644 index cdfcf60..0000000 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java.orig +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.drill.exec.server; - -import io.netty.channel.nio.NioEventLoopGroup; - -import java.util.Collection; - -import org.apache.drill.common.config.DrillConfig; -import org.apache.drill.common.exceptions.ExecutionSetupException; -import org.apache.drill.exec.cache.DistributedCache; -import org.apache.drill.exec.cache.DistributedMultiMap; -import org.apache.drill.exec.coord.ClusterCoordinator; -import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry; -import org.apache.drill.exec.memory.BufferAllocator; -import org.apache.drill.exec.physical.impl.OperatorCreatorRegistry; -import org.apache.drill.exec.planner.PhysicalPlanReader; -import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; -import org.apache.drill.exec.rpc.control.Controller; -import org.apache.drill.exec.rpc.control.WorkEventBus; -import org.apache.drill.exec.rpc.data.DataConnectionCreator; -import org.apache.drill.exec.store.StoragePluginRegistry; -import org.apache.drill.exec.store.StoragePluginRegistry.DrillSchemaFactory; -import org.apache.drill.exec.store.StoragePlugin; - -import com.codahale.metrics.MetricRegistry; -import com.google.common.base.Preconditions; - -public class DrillbitContext { - static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillbitContext.class); - - private final BootStrapContext context; - - private PhysicalPlanReader reader; - private final ClusterCoordinator coord; - private final DataConnectionCreator connectionsPool; - private final DistributedCache cache; - private final DrillbitEndpoint endpoint; - private final StoragePluginRegistry storagePlugins; - private final OperatorCreatorRegistry operatorCreatorRegistry; - private final Controller controller; - private final WorkEventBus workBus; - private final FunctionImplementationRegistry functionRegistry; -<<<<<<< HEAD - -======= - private final DistributedGlobalOptions globalDrillOptions; - ->>>>>>> Drill 381 - implementation of session and global options. - public DrillbitContext(DrillbitEndpoint endpoint, BootStrapContext context, ClusterCoordinator coord, Controller controller, DataConnectionCreator connectionsPool, DistributedCache cache, WorkEventBus workBus) { - super(); - Preconditions.checkNotNull(endpoint); - Preconditions.checkNotNull(context); - Preconditions.checkNotNull(controller); - Preconditions.checkNotNull(connectionsPool); - this.workBus = workBus; - this.controller = controller; - this.context = context; - this.coord = coord; - this.connectionsPool = connectionsPool; - this.cache = cache; - this.endpoint = endpoint; - this.storagePlugins = new StoragePluginRegistry(this); - this.reader = new PhysicalPlanReader(context.getConfig(), context.getConfig().getMapper(), endpoint, storagePlugins); - this.operatorCreatorRegistry = new OperatorCreatorRegistry(context.getConfig()); - this.functionRegistry = new FunctionImplementationRegistry(context.getConfig()); - this.globalDrillOptions = new DistributedGlobalOptions(this.cache); - } - -<<<<<<< HEAD -======= - ->>>>>>> Drill 381 - implementation of session and global options. - public FunctionImplementationRegistry getFunctionImplementationRegistry() { - return functionRegistry; - } - - public WorkEventBus getWorkBus(){ - return workBus; - } -<<<<<<< HEAD -======= - - public DistributedGlobalOptions getGlobalDrillOptions() { - return globalDrillOptions; - } ->>>>>>> Drill 381 - implementation of session and global options. - - public DrillbitEndpoint getEndpoint(){ - return endpoint; - } - - public DrillConfig getConfig() { - return context.getConfig(); - } - - public Collection<DrillbitEndpoint> getBits(){ - return coord.getAvailableEndpoints(); - } - - public BufferAllocator getAllocator(){ - return context.getAllocator(); - } - - public OperatorCreatorRegistry getOperatorCreatorRegistry() { - return operatorCreatorRegistry; - } - - public StoragePluginRegistry getStorage(){ - return this.storagePlugins; - } - - public NioEventLoopGroup getBitLoopGroup(){ - return context.getBitLoopGroup(); - } - - - public DataConnectionCreator getDataConnectionsPool(){ - return connectionsPool; - } - - public Controller getController(){ - return controller; - } - - public MetricRegistry getMetrics(){ - return context.getMetrics(); - } - - public DistributedCache getCache(){ - return cache; - } - - public PhysicalPlanReader getPlanReader(){ - return reader; - } - - public DrillSchemaFactory getSchemaFactory(){ - return storagePlugins.getSchemaFactory(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/c5f5e282/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistry.java.orig ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistry.java.orig b/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistry.java.orig deleted file mode 100644 index 2c75651..0000000 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistry.java.orig +++ /dev/null @@ -1,243 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.drill.exec.store; - -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.net.URL; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import com.google.common.base.Preconditions; -import net.hydromatic.linq4j.expressions.DefaultExpression; -import net.hydromatic.linq4j.expressions.Expression; -import net.hydromatic.optiq.SchemaPlus; -import net.hydromatic.optiq.tools.RuleSet; - -import org.apache.drill.common.config.DrillConfig; -import org.apache.drill.common.exceptions.ExecutionSetupException; -import org.apache.drill.common.logical.FormatPluginConfig; -import org.apache.drill.common.logical.StoragePluginConfig; -import org.apache.drill.common.util.PathScanner; -import org.apache.drill.exec.ExecConstants; -import org.apache.drill.exec.planner.logical.DrillRuleSets; -import org.apache.drill.exec.cache.DistributedMap; -import org.apache.drill.exec.cache.JacksonDrillSerializable.StoragePluginsSerializable; -import org.apache.drill.exec.exception.DrillbitStartupException; -import org.apache.drill.exec.planner.logical.StoragePlugins; -import org.apache.drill.exec.rpc.user.DrillUser; -import org.apache.drill.exec.server.DrillbitContext; -import org.apache.drill.exec.store.dfs.FileSystemPlugin; -import org.apache.drill.exec.store.dfs.FormatPlugin; -import org.apache.drill.exec.store.ischema.InfoSchemaConfig; -import org.apache.drill.exec.store.ischema.InfoSchemaStoragePlugin; -import org.eigenbase.relopt.RelOptRule; - -import com.google.common.base.Charsets; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.common.io.Resources; -import org.apache.drill.exec.store.options.OptionValueStorageConfig; -import org.apache.drill.exec.store.options.OptionValueStoragePlugin; - - -public class StoragePluginRegistry implements Iterable<Map.Entry<String, StoragePlugin>>{ - static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StoragePluginRegistry.class); - - private Map<Object, Constructor<? extends StoragePlugin>> availablePlugins = new HashMap<Object, Constructor<? extends StoragePlugin>>(); - private ImmutableMap<String, StoragePlugin> plugins; - - private DrillbitContext context; - private final DrillSchemaFactory schemaFactory = new DrillSchemaFactory(); - - private RuleSet storagePluginsRuleSet; - - private static final Expression EXPRESSION = new DefaultExpression(Object.class); - - public StoragePluginRegistry(DrillbitContext context) { - try{ - this.context = context; - }catch(RuntimeException e){ - logger.error("Failure while loading storage plugin registry.", e); - throw new RuntimeException("Faiure while reading and loading storage plugin configuration.", e); - } - } - - @SuppressWarnings("unchecked") - public void init() throws DrillbitStartupException { - DrillConfig config = context.getConfig(); - Collection<Class<? extends StoragePlugin>> plugins = PathScanner.scanForImplementations(StoragePlugin.class, config.getStringList(ExecConstants.STORAGE_ENGINE_SCAN_PACKAGES)); - logger.debug("Loading storage plugins {}", plugins); - for(Class<? extends StoragePlugin> plugin: plugins){ - int i =0; - for(Constructor<?> c : plugin.getConstructors()){ - Class<?>[] params = c.getParameterTypes(); - if(params.length != 3 - || params[1] != DrillbitContext.class - || !StoragePluginConfig.class.isAssignableFrom(params[0]) - || params[2] != String.class){ - logger.info("Skipping StoragePlugin constructor {} for plugin class {} since it doesn't implement a [constructor(StoragePluginConfig, DrillbitContext, String)]", c, plugin); - continue; - } - availablePlugins.put(params[0], (Constructor<? extends StoragePlugin>) c); - i++; - } - if(i == 0){ - logger.debug("Skipping registration of StoragePlugin {} as it doesn't have a constructor with the parameters of (StorangePluginConfig, Config)", plugin.getCanonicalName()); - } - } - - // create registered plugins defined in "storage-plugins.json" - this.plugins = ImmutableMap.copyOf(createPlugins()); - - // query registered engines for optimizer rules and build the storage plugin RuleSet - Builder<RelOptRule> setBuilder = ImmutableSet.builder(); - for (StoragePlugin plugin : this.plugins.values()) { - Set<StoragePluginOptimizerRule> rules = plugin.getOptimizerRules(); - if (rules != null && rules.size() > 0) { - setBuilder.addAll(rules); - } - } - this.storagePluginsRuleSet = DrillRuleSets.create(setBuilder.build()); - } - - private Map<String, StoragePlugin> createPlugins() throws DrillbitStartupException { - /* - * Check if "storage-plugins.json" exists. Also check if "storage-plugins" object exists in Distributed Cache. - * If both exist, check that they are the same. If they differ, throw exception. If "storage-plugins.json" exists, but - * nothing found in cache, then add it to the cache. If neither are found, throw exception. - */ - StoragePlugins plugins = null; - StoragePlugins cachedPlugins = null; - Map<String, StoragePlugin> activePlugins = new HashMap<String, StoragePlugin>(); - try{ - URL url = Resources.class.getClassLoader().getResource("storage-plugins.json"); - if (url != null) { - String pluginsData = Resources.toString(url, Charsets.UTF_8); - plugins = context.getConfig().getMapper().readValue(pluginsData, StoragePlugins.class); - } - DistributedMap<StoragePluginsSerializable> map = context.getCache().getMap(StoragePluginsSerializable.class); - StoragePluginsSerializable cachedPluginsSerializable = map.get("storage-plugins"); - if (cachedPluginsSerializable != null) { - cachedPlugins = cachedPluginsSerializable.getObj(); - logger.debug("Found cached storage plugin config: {}", cachedPlugins); - } else { - Preconditions.checkNotNull(plugins,"No storage plugin configuration found"); - logger.debug("caching storage plugin config {}", plugins); - map.put("storage-plugins", new StoragePluginsSerializable(context, plugins)); - cachedPluginsSerializable = map.get("storage-plugins"); - cachedPlugins = cachedPluginsSerializable.getObj(); - } - if(!(plugins == null || cachedPlugins.equals(plugins))) { - logger.error("Storage plugin config mismatch. {}. {}", plugins, cachedPlugins); - throw new DrillbitStartupException("Storage plugin config mismatch"); - } - logger.debug("using plugin config: {}", cachedPlugins); - }catch(IOException e){ - throw new IllegalStateException("Failure while reading storage plugins data.", e); - } - - for(Map.Entry<String, StoragePluginConfig> config : cachedPlugins){ - try{ - StoragePlugin plugin = create(config.getKey(), config.getValue()); - activePlugins.put(config.getKey(), plugin); - }catch(ExecutionSetupException e){ - logger.error("Failure while setting up StoragePlugin with name: '{}'.", config.getKey(), e); - } - } -<<<<<<< HEAD - activePlugins.put("INFORMATION_SCHEMA", new InfoSchemaStoragePlugin(new InfoSchemaConfig(), context, "INFORMATION_SCHEMA")); - - return activePlugins; -======= - activeEngines.put("INFORMATION_SCHEMA", new InfoSchemaStoragePlugin(new InfoSchemaConfig(), context, "INFORMATION_SCHEMA")); - activeEngines.put("OPTIONS", new OptionValueStoragePlugin(new OptionValueStorageConfig(), context, "OPTIONS")); - - return activeEngines; ->>>>>>> Drill 381 - implementation of session and global options. - } - - public StoragePlugin getPlugin(String registeredStoragePluginName) throws ExecutionSetupException { - return plugins.get(registeredStoragePluginName); - } - - public StoragePlugin getPlugin(StoragePluginConfig config) throws ExecutionSetupException { - if(config instanceof NamedStoragePluginConfig){ - return plugins.get(((NamedStoragePluginConfig) config).name); - }else{ - // TODO: for now, we'll throw away transient configs. we really ought to clean these up. - return create(null, config); - } - } - - public FormatPlugin getFormatPlugin(StoragePluginConfig storageConfig, FormatPluginConfig formatConfig) throws ExecutionSetupException{ - StoragePlugin p = getPlugin(storageConfig); - if(!(p instanceof FileSystemPlugin)) throw new ExecutionSetupException(String.format("You tried to request a format plugin for a storage plugin that wasn't of type FileSystemPlugin. The actual type of plugin was %s.", p.getClass().getName())); - FileSystemPlugin storage = (FileSystemPlugin) p; - return storage.getFormatPlugin(formatConfig); - } - - private StoragePlugin create(String name, StoragePluginConfig pluginConfig) throws ExecutionSetupException { - StoragePlugin plugin = null; - Constructor<? extends StoragePlugin> c = availablePlugins.get(pluginConfig.getClass()); - if (c == null) - throw new ExecutionSetupException(String.format("Failure finding StoragePlugin constructor for config %s", - pluginConfig)); - try { - plugin = c.newInstance(pluginConfig, context, name); - return plugin; - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Throwable t = e instanceof InvocationTargetException ? ((InvocationTargetException) e).getTargetException() : e; - if (t instanceof ExecutionSetupException) - throw ((ExecutionSetupException) t); - throw new ExecutionSetupException(String.format( - "Failure setting up new storage plugin configuration for config %s", pluginConfig), t); - } - } - - @Override - public Iterator<Entry<String, StoragePlugin>> iterator() { - return plugins.entrySet().iterator(); - } - - public RuleSet getStoragePluginRuleSet() { - return storagePluginsRuleSet; - } - - public DrillSchemaFactory getSchemaFactory(){ - return schemaFactory; - } - - public class DrillSchemaFactory implements SchemaFactory{ - - @Override - public void registerSchemas(DrillUser user, SchemaPlus parent) { - for(Map.Entry<String, StoragePlugin> e : plugins.entrySet()){ - e.getValue().registerSchemas(user, parent); - } - } - - } - -}
