[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16481026#comment-16481026 ] ASF GitHub Bot commented on DRILL-6255: --- asfgit closed pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BitRpcUtility.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BitRpcUtility.java index c3980336f7..0bc01f5367 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BitRpcUtility.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/BitRpcUtility.java @@ -103,6 +103,24 @@ void prepareSaslHandshake(final RpcConnectionHandler connectionHandler, List } } + /** + * Verifies if local and remote Drillbit Endpoint has same control server by using address and control port + * information. This method is used instead of equals in {@link DrillbitEndpoint} because DrillbitEndpoint stores + * state information in it. + * For local Drillbit a reference is stored in {@link org.apache.drill.exec.server.DrillbitContext} as soon as + * Drillbit is started in {@link org.apache.drill.exec.service.ServiceEngine#start} with state as STARTUP, but + * while planning minor fragment the assignment list is used from active list of Drillbits in which state for local + * Drillbit will not be STARTUP + * @param local - DrillbitEndpoint instance for local bit + * @param remote - DrillbitEndpoint instance for remote bit + * @return true if address and control port for local and remote are same. + * false - otherwise + */ + public static boolean isLocalControlServer(DrillbitEndpoint local, DrillbitEndpoint remote) { +return local.hasAddress() && local.hasControlPort() && remote.hasAddress() && remote.hasControlPort() && + local.getAddress().equals(remote.getAddress()) && local.getControlPort() == remote.getControlPort(); + } + // Suppress default constructor private BitRpcUtility() { } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ConnectionManagerRegistry.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ConnectionManagerRegistry.java index 800cf3cc85..e27729c1f4 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ConnectionManagerRegistry.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ConnectionManagerRegistry.java @@ -23,6 +23,7 @@ import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; import com.google.common.collect.Maps; +import org.apache.drill.exec.rpc.BitRpcUtility; public class ConnectionManagerRegistry implements Iterable { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ConnectionManagerRegistry.class); @@ -40,9 +41,12 @@ public ConnectionManagerRegistry(ControlConnectionConfig config) { public ControlConnectionManager getConnectionManager(DrillbitEndpoint remoteEndpoint) { assert localEndpoint != null : "DrillbitEndpoint must be set before a connection manager can be retrieved"; + +final boolean isLocalServer = BitRpcUtility.isLocalControlServer(localEndpoint, remoteEndpoint); ControlConnectionManager m = registry.get(remoteEndpoint); if (m == null) { - m = new ControlConnectionManager(config, localEndpoint, remoteEndpoint); + m = (isLocalServer) ? new LocalControlConnectionManager(config, remoteEndpoint) +: new RemoteControlConnectionManager(config, localEndpoint, remoteEndpoint); final ControlConnectionManager m2 = registry.putIfAbsent(remoteEndpoint, m); if (m2 != null) { m = m2; diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControlConnectionConfig.java b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControlConnectionConfig.java index b19fb8bb75..f114af44de 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControlConnectionConfig.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControlConnectionConfig.java @@ -17,6 +17,7 @@ */ package org.apache.drill.exec.rpc.control; +import com.google.common.annotations.VisibleForTesting; import org.apache.drill.exec.exception.DrillbitStartupException; import org.apache.drill.exec.memory.BufferAllocator; import org.apache.drill.exec.rpc.BitConnectionConfig; @@ -24,8 +25,8 @@ import org.apache.drill.exec.work.batch.ControlMessageHandler; // config for bit to bit connection -// package private
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16478788#comment-16478788 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on issue #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#issuecomment-389800186 +1, LGTM. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16477932#comment-16477932 ] ASF GitHub Bot commented on DRILL-6255: --- sohami commented on issue #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#issuecomment-389632999 @arina-ielchiieva - Made all the changes, rebased and squashed the commits. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16477124#comment-16477124 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188553073 ## File path: exec/java-exec/src/test/java/org/apache/drill/exec/rpc/control/TestLocalControlConnectionManager.java ## @@ -0,0 +1,278 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.ExecProtos; +import org.apache.drill.exec.proto.GeneralRPCProtos; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.Acks; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.concurrent.CountDownLatch; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class TestLocalControlConnectionManager { + + private static final DrillbitEndpoint localEndpoint = DrillbitEndpoint.newBuilder() +.setAddress("10.0.0.1") +.setControlPort(31011) +.setState(DrillbitEndpoint.State.STARTUP) +.build(); + + private static ControlConnectionConfig mockConfig; + + private static ControlMessageHandler mockHandler; + + private static ControlTunnel controlTunnel; + + private CountDownLatch latch; + + private final String negativeAckMessage = "Negative Ack received"; + + private final RpcOutcomeListener outcomeListener = Review comment: static This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16477121#comment-16477121 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188552805 ## File path: exec/java-exec/src/test/java/org/apache/drill/exec/rpc/control/ConnectionManagerRegistryTest.java ## @@ -0,0 +1,149 @@ +/* + * 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.rpc.control; + +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +public class ConnectionManagerRegistryTest { + + private final DrillbitEndpoint localEndpoint = DrillbitEndpoint.newBuilder() Review comment: static here and for `foremanEndpoint`. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16477123#comment-16477123 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188553012 ## File path: exec/java-exec/src/test/java/org/apache/drill/exec/rpc/control/TestLocalControlConnectionManager.java ## @@ -0,0 +1,278 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.ExecProtos; +import org.apache.drill.exec.proto.GeneralRPCProtos; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.Acks; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.concurrent.CountDownLatch; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class TestLocalControlConnectionManager { + + private static final DrillbitEndpoint localEndpoint = DrillbitEndpoint.newBuilder() +.setAddress("10.0.0.1") +.setControlPort(31011) +.setState(DrillbitEndpoint.State.STARTUP) +.build(); + + private static ControlConnectionConfig mockConfig; + + private static ControlMessageHandler mockHandler; + + private static ControlTunnel controlTunnel; + + private CountDownLatch latch; + + private final String negativeAckMessage = "Negative Ack received"; Review comment: static This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16477122#comment-16477122 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188552176 ## File path: exec/java-exec/src/test/java/org/apache/drill/exec/rpc/control/TestLocalControlConnectionManager.java ## @@ -55,6 +58,8 @@ private CountDownLatch latch; + private final String negativeAckMessage = "Negative Ack received"; Review comment: static? and `NEGATIVE_ACK_MESSAGE`. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16477120#comment-16477120 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188551014 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/ControlConnectionConfig.java ## @@ -24,8 +24,8 @@ import org.apache.drill.exec.work.batch.ControlMessageHandler; // config for bit to bit connection -// package private -class ControlConnectionConfig extends BitConnectionConfig { +// public for testing purpose Review comment: Another option is to use `@VisibleForTesting` annotation. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16475307#comment-16475307 ] ASF GitHub Bot commented on DRILL-6255: --- ilooner commented on issue #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#issuecomment-389050187 @sohami Please fix Travis failures ``` Tests in error: TestLocalControlConnectionManager.setupForTest:101 WrongTypeOfReturnValue Con... TestLocalControlConnectionManager.setupForTest:101 MissingMethodInvocation wh... TestLocalControlConnectionManager.setupForTest:101 MissingMethodInvocation wh... TestLocalControlConnectionManager.setupForTest:101 MissingMethodInvocation wh... TestLocalControlConnectionManager.setupForTest:101 MissingMethodInvocation wh... TestLocalControlConnectionManager.setupForTest:101 MissingMethodInvocation wh... TestLocalControlConnectionManager.setupForTest:101 MissingMethodInvocation wh... TestLocalControlConnectionManager.setupForTest:101 MissingMethodInvocation wh... TestLocalControlConnectionManager.setupForTest:101 MissingMethodInvocation wh... TestLocalControlConnectionManager.setupForTest:101 MissingMethodInvocation wh... TestLocalControlConnectionManager.setupForTest:101 MissingMethodInvocation wh... TestLocalControlConnectionManager.setupForTest:101 MissingMethodInvocation wh... ``` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16475047#comment-16475047 ] ASF GitHub Bot commented on DRILL-6255: --- sohami commented on issue #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#issuecomment-388995280 Rebased on top of latest master This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16475042#comment-16475042 ] ASF GitHub Bot commented on DRILL-6255: --- sohami commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188097298 ## File path: exec/rpc/src/main/java/org/apache/drill/exec/rpc/FutureBitCommand.java ## @@ -71,10 +73,15 @@ public void interrupted(final InterruptedException e) { return parentFuture; } + @Override + public RpcOutcomeListener getOutcomeListener() { +return outcomeListener; + } + @Override public void connectionFailed(FailureType type, Throwable t) { settableFuture.setException(RpcException.mapException( String.format("Command failed while establishing connection. Failure type %s.", type), t)); } -} \ No newline at end of file +} Review comment: Added intentionally as it's recommended. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16475040#comment-16475040 ] ASF GitHub Bot commented on DRILL-6255: --- sohami commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188090731 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java ## @@ -180,44 +170,38 @@ private void setupNonRootFragments(final Collection fragments) thr foreman.getQueryManager().addFragmentStatusTracker(planFragment, false); if (planFragment.getLeafFragment()) { -updateFragmentCollection(planFragment, localDrillbitEndpoint, localLeafFragmentList, remoteLeafFragmentMap); +leafFragmentMap.put(planFragment.getAssignment(), planFragment); } else { -updateFragmentCollection(planFragment, localDrillbitEndpoint, localIntFragmentList, remoteIntFragmentMap); +intFragmentMap.put(planFragment.getAssignment(), planFragment); } } /* * We need to wait for the intermediates to be sent so that they'll be set up by the time - * the leaves start producing data. We'll use this latch to wait for the responses. + * the leaves start producing data. We'll use this latch to wait for the responses. All the local intermediate + * fragments are submitted locally without creating any actual control connection to itself. * * However, in order not to hang the process if any of the RPC requests fails, we always * count down (see FragmentSubmitFailures), but we count the number of failures so that we'll * know if any submissions did fail. */ -scheduleRemoteIntermediateFragments(remoteIntFragmentMap); - -// Setup local intermediate fragments -for (final PlanFragment fragment : localIntFragmentList) { - startLocalFragment(fragment); -} +scheduleRemoteIntermediateFragments(intFragmentMap); injector.injectChecked(foreman.getQueryContext().getExecutionControls(), "send-fragments", ForemanException.class); /* * Send the remote (leaf) fragments; we don't wait for these. Any problems will come in through - * the regular sendListener event delivery. + * the regular sendListener event delivery˚. All the local leaf fragments are submitted locally without creating + * any actual control connection to itself. */ -for (final DrillbitEndpoint ep : remoteLeafFragmentMap.keySet()) { - sendRemoteFragments(ep, remoteLeafFragmentMap.get(ep), null, null); -} - -// Setup local leaf fragments -for (final PlanFragment fragment : localLeafFragmentList) { - startLocalFragment(fragment); +for (final DrillbitEndpoint ep : leafFragmentMap.keySet()) { + sendRemoteFragments(ep, leafFragmentMap.get(ep), null, null); } } /** - * Send all the remote fragments belonging to a single target drillbit in one request. + * Send all the remote fragments belonging to a single target drillbit in one request. If the assignment Review comment: renamed `scheduleRemoteIntermediateFragments` to `scheduleIntermediateFragments` but kept `sendRemoteFragments` as is since it's used to send intermediate fragments as well not just leaf fragments. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16475046#comment-16475046 ] ASF GitHub Bot commented on DRILL-6255: --- sohami commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188096274 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/LocalControlConnectionManager.java ## @@ -0,0 +1,236 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.DrillBuf; +import org.apache.drill.exec.exception.OutOfMemoryException; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.GeneralRPCProtos.Ack; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.BasicClient; +import org.apache.drill.exec.rpc.Response; +import org.apache.drill.exec.rpc.RpcCommand; +import org.apache.drill.exec.rpc.RpcConstants; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; + +public class LocalControlConnectionManager extends ControlConnectionManager { + private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LocalControlConnectionManager.class); + + private final ControlConnectionConfig config; + + public LocalControlConnectionManager(ControlConnectionConfig config, DrillbitEndpoint localEndpoint) { +super(localEndpoint, localEndpoint); +this.config = config; + } + + @Override + protected BasicClient getNewClient() { +throw new UnsupportedOperationException("LocalControlConnectionManager doesn't support creating a control client"); + } + + @Override + public void runCommand(RpcCommand cmd) { +final int rpcType = cmd.getRpcType().getNumber(); +final ControlMessageHandler messageHandler = config.getMessageHandler(); + +if (RpcConstants.EXTRA_DEBUGGING) { + logger.debug("Received bit com message of type {} over local connection manager", rpcType); +} + +switch (rpcType) { + + case BitControl.RpcType.REQ_CANCEL_FRAGMENT_VALUE: { +final ControlTunnel.SignalFragment signalFragment = ((ControlTunnel.SignalFragment) cmd); +final RpcOutcomeListener outcomeListener = signalFragment.getOutcomeListener(); +final Ack ackResponse = messageHandler.cancelFragment(signalFragment.getMessage()); +outcomeListener.success(ackResponse, null); +break; + } + + case BitControl.RpcType.REQ_CUSTOM_VALUE: { +final ByteBuf[] dataBodies; +final RpcOutcomeListener outcomeListener; + +if (cmd instanceof ControlTunnel.CustomMessageSender) { + dataBodies = ((ControlTunnel.CustomMessageSender)cmd).getDataBodies(); + outcomeListener = ((ControlTunnel.CustomMessageSender)cmd).getOutcomeListener(); +} else if (cmd instanceof ControlTunnel.SyncCustomMessageSender) { + dataBodies = ((ControlTunnel.SyncCustomMessageSender)cmd).getDataBodies(); + outcomeListener = ((ControlTunnel.SyncCustomMessageSender)cmd).getOutcomeListener(); +} else { + throw new UnsupportedOperationException("Unknown Custom Type control message received"); +} + +DrillBuf reqDrillBuff; +try { + reqDrillBuff = convertToByteBuf(dataBodies); +} catch (Exception ex) { + outcomeListener.failed(new RpcException("Failed to allocate memory while sending request in " + +"LocalControlConnectionManager#convertToByteBuff", ex)); + return; +} finally { + releaseByteBuf(dataBodies); +} + +try { + BitControl.CustomMessage message = (BitControl.CustomMessage) cmd.getMessage(); + final Response response = messageHandler.getHandlerRegistry().handle(message, reqDrillBuff); + DrillBuf
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16475045#comment-16475045 ] ASF GitHub Bot commented on DRILL-6255: --- sohami commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188096939 ## File path: exec/java-exec/src/test/java/org/apache/drill/exec/rpc/control/TestLocalControlConnectionManager.java ## @@ -0,0 +1,304 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.ExecProtos; +import org.apache.drill.exec.proto.GeneralRPCProtos; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.Acks; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.concurrent.CountDownLatch; + +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class TestLocalControlConnectionManager { + + private static final DrillbitEndpoint localEndpoint = DrillbitEndpoint.newBuilder() +.setAddress("10.0.0.1") +.setControlPort(31011) +.setState(DrillbitEndpoint.State.STARTUP) +.build(); + + private static ControlConnectionConfig mockConfig; + + private static ControlMessageHandler mockHandler; + + private static ControlTunnel controlTunnel; + + private CountDownLatch latch; + + private final RpcOutcomeListener outcomeListener = +new RpcOutcomeListener() { +@Override +public void failed(RpcException ex) { + throw new IllegalStateException(ex); +} + +@Override +public void success(GeneralRPCProtos.Ack value, ByteBuf buffer) { + if (value.getOk()) { +latch.countDown(); + } else { +throw new IllegalStateException("Negative Ack received"); + } +} + +@Override +public void interrupted(InterruptedException e) { + Review comment: This is test specific implementation and am not testing the interrupted scenario hence no action. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16475041#comment-16475041 ] ASF GitHub Bot commented on DRILL-6255: --- sohami commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188090319 ## File path: exec/java-exec/src/test/java/org/apache/drill/exec/rpc/control/TestLocalControlConnectionManager.java ## @@ -0,0 +1,304 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.ExecProtos; +import org.apache.drill.exec.proto.GeneralRPCProtos; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.Acks; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.concurrent.CountDownLatch; + +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class TestLocalControlConnectionManager { + + private static final DrillbitEndpoint localEndpoint = DrillbitEndpoint.newBuilder() +.setAddress("10.0.0.1") +.setControlPort(31011) +.setState(DrillbitEndpoint.State.STARTUP) +.build(); + + private static ControlConnectionConfig mockConfig; + + private static ControlMessageHandler mockHandler; + + private static ControlTunnel controlTunnel; + + private CountDownLatch latch; + + private final RpcOutcomeListener outcomeListener = +new RpcOutcomeListener() { +@Override +public void failed(RpcException ex) { + throw new IllegalStateException(ex); +} + +@Override +public void success(GeneralRPCProtos.Ack value, ByteBuf buffer) { + if (value.getOk()) { +latch.countDown(); + } else { +throw new IllegalStateException("Negative Ack received"); + } +} + +@Override +public void interrupted(InterruptedException e) { + +} + }; + + @BeforeClass + public static void setup() { +mockConfig = mock(ControlConnectionConfig.class); +final ConnectionManagerRegistry registry = new ConnectionManagerRegistry(mockConfig); +registry.setLocalEndpoint(localEndpoint); +ControlConnectionManager manager = registry.getConnectionManager(localEndpoint); +assertTrue(manager instanceof LocalControlConnectionManager); +controlTunnel = new ControlTunnel(manager); + } + + @Before + public void setupForTest() { +mockHandler = mock(ControlMessageHandler.class); +when(mockConfig.getMessageHandler()).thenReturn(mockHandler); + } + + /** + * Verify that SendFragmentStatus is handled correctly using ControlTunnel with LocalControlConnectionManager + */ + @Test + public void testLocalSendFragmentStatus_Success() { +final UserBitShared.QueryId mockQueryId = UserBitShared.QueryId.getDefaultInstance(); +final UserBitShared.QueryProfile mockProfile = UserBitShared.QueryProfile.getDefaultInstance(); +try { Review comment: `checkedGet()` can throw an exception and it's not expected in these test cases. So in `catch` block we are failing the tests. But made the changes to remove those along with using `ExpectedException` rule in JUnit This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally >
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16475044#comment-16475044 ] ASF GitHub Bot commented on DRILL-6255: --- sohami commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188096235 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/LocalControlConnectionManager.java ## @@ -0,0 +1,236 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.DrillBuf; +import org.apache.drill.exec.exception.OutOfMemoryException; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.GeneralRPCProtos.Ack; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.BasicClient; +import org.apache.drill.exec.rpc.Response; +import org.apache.drill.exec.rpc.RpcCommand; +import org.apache.drill.exec.rpc.RpcConstants; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; + +public class LocalControlConnectionManager extends ControlConnectionManager { + private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LocalControlConnectionManager.class); + + private final ControlConnectionConfig config; + + public LocalControlConnectionManager(ControlConnectionConfig config, DrillbitEndpoint localEndpoint) { +super(localEndpoint, localEndpoint); +this.config = config; + } + + @Override + protected BasicClient getNewClient() { +throw new UnsupportedOperationException("LocalControlConnectionManager doesn't support creating a control client"); + } + + @Override + public void runCommand(RpcCommand cmd) { +final int rpcType = cmd.getRpcType().getNumber(); +final ControlMessageHandler messageHandler = config.getMessageHandler(); + +if (RpcConstants.EXTRA_DEBUGGING) { + logger.debug("Received bit com message of type {} over local connection manager", rpcType); +} + +switch (rpcType) { + + case BitControl.RpcType.REQ_CANCEL_FRAGMENT_VALUE: { +final ControlTunnel.SignalFragment signalFragment = ((ControlTunnel.SignalFragment) cmd); +final RpcOutcomeListener outcomeListener = signalFragment.getOutcomeListener(); +final Ack ackResponse = messageHandler.cancelFragment(signalFragment.getMessage()); +outcomeListener.success(ackResponse, null); +break; + } + + case BitControl.RpcType.REQ_CUSTOM_VALUE: { +final ByteBuf[] dataBodies; +final RpcOutcomeListener outcomeListener; + +if (cmd instanceof ControlTunnel.CustomMessageSender) { + dataBodies = ((ControlTunnel.CustomMessageSender)cmd).getDataBodies(); + outcomeListener = ((ControlTunnel.CustomMessageSender)cmd).getOutcomeListener(); +} else if (cmd instanceof ControlTunnel.SyncCustomMessageSender) { + dataBodies = ((ControlTunnel.SyncCustomMessageSender)cmd).getDataBodies(); + outcomeListener = ((ControlTunnel.SyncCustomMessageSender)cmd).getOutcomeListener(); +} else { + throw new UnsupportedOperationException("Unknown Custom Type control message received"); +} + +DrillBuf reqDrillBuff; +try { + reqDrillBuff = convertToByteBuf(dataBodies); +} catch (Exception ex) { + outcomeListener.failed(new RpcException("Failed to allocate memory while sending request in " + +"LocalControlConnectionManager#convertToByteBuff", ex)); + return; +} finally { + releaseByteBuf(dataBodies); +} + +try { + BitControl.CustomMessage message = (BitControl.CustomMessage) cmd.getMessage(); + final Response response = messageHandler.getHandlerRegistry().handle(message, reqDrillBuff); + DrillBuf
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16475043#comment-16475043 ] ASF GitHub Bot commented on DRILL-6255: --- sohami commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r188097134 ## File path: exec/rpc/src/main/java/org/apache/drill/exec/rpc/RpcCommand.java ## @@ -17,10 +17,16 @@ */ package org.apache.drill.exec.rpc; +import com.google.protobuf.Internal.EnumLite; import com.google.protobuf.MessageLite; public interface RpcCommand extends RpcConnectionHandler{ Review comment: Fixed This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16474290#comment-16474290 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r187977640 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/LocalControlConnectionManager.java ## @@ -0,0 +1,236 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.DrillBuf; +import org.apache.drill.exec.exception.OutOfMemoryException; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.GeneralRPCProtos.Ack; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.BasicClient; +import org.apache.drill.exec.rpc.Response; +import org.apache.drill.exec.rpc.RpcCommand; +import org.apache.drill.exec.rpc.RpcConstants; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; + +public class LocalControlConnectionManager extends ControlConnectionManager { + private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LocalControlConnectionManager.class); + + private final ControlConnectionConfig config; + + public LocalControlConnectionManager(ControlConnectionConfig config, DrillbitEndpoint localEndpoint) { +super(localEndpoint, localEndpoint); +this.config = config; + } + + @Override + protected BasicClient getNewClient() { +throw new UnsupportedOperationException("LocalControlConnectionManager doesn't support creating a control client"); + } + + @Override + public void runCommand(RpcCommand cmd) { +final int rpcType = cmd.getRpcType().getNumber(); +final ControlMessageHandler messageHandler = config.getMessageHandler(); + +if (RpcConstants.EXTRA_DEBUGGING) { + logger.debug("Received bit com message of type {} over local connection manager", rpcType); +} + +switch (rpcType) { + + case BitControl.RpcType.REQ_CANCEL_FRAGMENT_VALUE: { +final ControlTunnel.SignalFragment signalFragment = ((ControlTunnel.SignalFragment) cmd); +final RpcOutcomeListener outcomeListener = signalFragment.getOutcomeListener(); +final Ack ackResponse = messageHandler.cancelFragment(signalFragment.getMessage()); +outcomeListener.success(ackResponse, null); +break; + } + + case BitControl.RpcType.REQ_CUSTOM_VALUE: { +final ByteBuf[] dataBodies; +final RpcOutcomeListener outcomeListener; + +if (cmd instanceof ControlTunnel.CustomMessageSender) { + dataBodies = ((ControlTunnel.CustomMessageSender)cmd).getDataBodies(); + outcomeListener = ((ControlTunnel.CustomMessageSender)cmd).getOutcomeListener(); +} else if (cmd instanceof ControlTunnel.SyncCustomMessageSender) { + dataBodies = ((ControlTunnel.SyncCustomMessageSender)cmd).getDataBodies(); + outcomeListener = ((ControlTunnel.SyncCustomMessageSender)cmd).getOutcomeListener(); +} else { + throw new UnsupportedOperationException("Unknown Custom Type control message received"); +} + +DrillBuf reqDrillBuff; +try { + reqDrillBuff = convertToByteBuf(dataBodies); +} catch (Exception ex) { + outcomeListener.failed(new RpcException("Failed to allocate memory while sending request in " + +"LocalControlConnectionManager#convertToByteBuff", ex)); + return; +} finally { + releaseByteBuf(dataBodies); +} + +try { + BitControl.CustomMessage message = (BitControl.CustomMessage) cmd.getMessage(); + final Response response = messageHandler.getHandlerRegistry().handle(message, reqDrillBuff); +
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16474292#comment-16474292 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r187952040 ## File path: exec/rpc/src/main/java/org/apache/drill/exec/rpc/FutureBitCommand.java ## @@ -71,10 +73,15 @@ public void interrupted(final InterruptedException e) { return parentFuture; } + @Override + public RpcOutcomeListener getOutcomeListener() { +return outcomeListener; + } + @Override public void connectionFailed(FailureType type, Throwable t) { settableFuture.setException(RpcException.mapException( String.format("Command failed while establishing connection. Failure type %s.", type), t)); } -} \ No newline at end of file +} Review comment: New line. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16474289#comment-16474289 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r187950137 ## File path: exec/rpc/src/main/java/org/apache/drill/exec/rpc/RpcCommand.java ## @@ -17,10 +17,16 @@ */ package org.apache.drill.exec.rpc; +import com.google.protobuf.Internal.EnumLite; import com.google.protobuf.MessageLite; public interface RpcCommand extends RpcConnectionHandler{ - public abstract void connectionAvailable(C connection); + void connectionAvailable(C connection); -} \ No newline at end of file + EnumLite getRpcType(); + + MessageLite getMessage(); + + RpcOutcomeListener getOutcomeListener(); +} Review comment: New line. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16474298#comment-16474298 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r187971211 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/LocalControlConnectionManager.java ## @@ -0,0 +1,236 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.DrillBuf; +import org.apache.drill.exec.exception.OutOfMemoryException; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.GeneralRPCProtos.Ack; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.BasicClient; +import org.apache.drill.exec.rpc.Response; +import org.apache.drill.exec.rpc.RpcCommand; +import org.apache.drill.exec.rpc.RpcConstants; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; + +public class LocalControlConnectionManager extends ControlConnectionManager { + private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LocalControlConnectionManager.class); + + private final ControlConnectionConfig config; + + public LocalControlConnectionManager(ControlConnectionConfig config, DrillbitEndpoint localEndpoint) { +super(localEndpoint, localEndpoint); +this.config = config; + } + + @Override + protected BasicClient getNewClient() { +throw new UnsupportedOperationException("LocalControlConnectionManager doesn't support creating a control client"); + } + + @Override + public void runCommand(RpcCommand cmd) { +final int rpcType = cmd.getRpcType().getNumber(); +final ControlMessageHandler messageHandler = config.getMessageHandler(); + +if (RpcConstants.EXTRA_DEBUGGING) { + logger.debug("Received bit com message of type {} over local connection manager", rpcType); +} + +switch (rpcType) { + + case BitControl.RpcType.REQ_CANCEL_FRAGMENT_VALUE: { +final ControlTunnel.SignalFragment signalFragment = ((ControlTunnel.SignalFragment) cmd); +final RpcOutcomeListener outcomeListener = signalFragment.getOutcomeListener(); +final Ack ackResponse = messageHandler.cancelFragment(signalFragment.getMessage()); +outcomeListener.success(ackResponse, null); +break; + } + + case BitControl.RpcType.REQ_CUSTOM_VALUE: { +final ByteBuf[] dataBodies; +final RpcOutcomeListener outcomeListener; + +if (cmd instanceof ControlTunnel.CustomMessageSender) { + dataBodies = ((ControlTunnel.CustomMessageSender)cmd).getDataBodies(); + outcomeListener = ((ControlTunnel.CustomMessageSender)cmd).getOutcomeListener(); +} else if (cmd instanceof ControlTunnel.SyncCustomMessageSender) { + dataBodies = ((ControlTunnel.SyncCustomMessageSender)cmd).getDataBodies(); + outcomeListener = ((ControlTunnel.SyncCustomMessageSender)cmd).getOutcomeListener(); +} else { + throw new UnsupportedOperationException("Unknown Custom Type control message received"); +} + +DrillBuf reqDrillBuff; +try { + reqDrillBuff = convertToByteBuf(dataBodies); +} catch (Exception ex) { + outcomeListener.failed(new RpcException("Failed to allocate memory while sending request in " + +"LocalControlConnectionManager#convertToByteBuff", ex)); + return; +} finally { + releaseByteBuf(dataBodies); +} + +try { + BitControl.CustomMessage message = (BitControl.CustomMessage) cmd.getMessage(); + final Response response = messageHandler.getHandlerRegistry().handle(message, reqDrillBuff); +
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16474296#comment-16474296 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r187956460 ## File path: exec/java-exec/src/test/java/org/apache/drill/exec/rpc/control/TestLocalControlConnectionManager.java ## @@ -0,0 +1,304 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.ExecProtos; +import org.apache.drill.exec.proto.GeneralRPCProtos; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.Acks; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.concurrent.CountDownLatch; + +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class TestLocalControlConnectionManager { + + private static final DrillbitEndpoint localEndpoint = DrillbitEndpoint.newBuilder() +.setAddress("10.0.0.1") +.setControlPort(31011) +.setState(DrillbitEndpoint.State.STARTUP) +.build(); + + private static ControlConnectionConfig mockConfig; + + private static ControlMessageHandler mockHandler; + + private static ControlTunnel controlTunnel; + + private CountDownLatch latch; + + private final RpcOutcomeListener outcomeListener = +new RpcOutcomeListener() { +@Override +public void failed(RpcException ex) { + throw new IllegalStateException(ex); +} + +@Override +public void success(GeneralRPCProtos.Ack value, ByteBuf buffer) { + if (value.getOk()) { +latch.countDown(); + } else { +throw new IllegalStateException("Negative Ack received"); + } +} + +@Override +public void interrupted(InterruptedException e) { + +} + }; + + @BeforeClass + public static void setup() { +mockConfig = mock(ControlConnectionConfig.class); +final ConnectionManagerRegistry registry = new ConnectionManagerRegistry(mockConfig); +registry.setLocalEndpoint(localEndpoint); +ControlConnectionManager manager = registry.getConnectionManager(localEndpoint); +assertTrue(manager instanceof LocalControlConnectionManager); +controlTunnel = new ControlTunnel(manager); + } + + @Before + public void setupForTest() { +mockHandler = mock(ControlMessageHandler.class); +when(mockConfig.getMessageHandler()).thenReturn(mockHandler); + } + + /** + * Verify that SendFragmentStatus is handled correctly using ControlTunnel with LocalControlConnectionManager + */ + @Test + public void testLocalSendFragmentStatus_Success() { +final UserBitShared.QueryId mockQueryId = UserBitShared.QueryId.getDefaultInstance(); +final UserBitShared.QueryProfile mockProfile = UserBitShared.QueryProfile.getDefaultInstance(); +try { + when(mockHandler.requestQueryStatus(mockQueryId)).thenReturn(mockProfile); + final UserBitShared.QueryProfile returnedProfile = controlTunnel.requestQueryProfile(mockQueryId).checkedGet(); + assertEquals(returnedProfile, mockProfile); +} catch (Exception ex) { + fail(); +} + } + + /** + * Verify that SendFragmentStatus failure scenario is handled correctly using ControlTunnel with + * LocalControlConnectionManager + */ + @Test + public void testLocalSendFragmentStatus_Failure() { +final UserBitShared.QueryId mockQueryId = UserBitShared.QueryId.getDefaultInstance(); +try { +
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16474295#comment-16474295 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r187971417 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/rpc/control/LocalControlConnectionManager.java ## @@ -0,0 +1,236 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.DrillBuf; +import org.apache.drill.exec.exception.OutOfMemoryException; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.GeneralRPCProtos.Ack; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.BasicClient; +import org.apache.drill.exec.rpc.Response; +import org.apache.drill.exec.rpc.RpcCommand; +import org.apache.drill.exec.rpc.RpcConstants; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; + +public class LocalControlConnectionManager extends ControlConnectionManager { + private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LocalControlConnectionManager.class); + + private final ControlConnectionConfig config; + + public LocalControlConnectionManager(ControlConnectionConfig config, DrillbitEndpoint localEndpoint) { +super(localEndpoint, localEndpoint); +this.config = config; + } + + @Override + protected BasicClient getNewClient() { +throw new UnsupportedOperationException("LocalControlConnectionManager doesn't support creating a control client"); + } + + @Override + public void runCommand(RpcCommand cmd) { +final int rpcType = cmd.getRpcType().getNumber(); +final ControlMessageHandler messageHandler = config.getMessageHandler(); + +if (RpcConstants.EXTRA_DEBUGGING) { + logger.debug("Received bit com message of type {} over local connection manager", rpcType); +} + +switch (rpcType) { + + case BitControl.RpcType.REQ_CANCEL_FRAGMENT_VALUE: { +final ControlTunnel.SignalFragment signalFragment = ((ControlTunnel.SignalFragment) cmd); +final RpcOutcomeListener outcomeListener = signalFragment.getOutcomeListener(); +final Ack ackResponse = messageHandler.cancelFragment(signalFragment.getMessage()); +outcomeListener.success(ackResponse, null); +break; + } + + case BitControl.RpcType.REQ_CUSTOM_VALUE: { +final ByteBuf[] dataBodies; +final RpcOutcomeListener outcomeListener; + +if (cmd instanceof ControlTunnel.CustomMessageSender) { + dataBodies = ((ControlTunnel.CustomMessageSender)cmd).getDataBodies(); + outcomeListener = ((ControlTunnel.CustomMessageSender)cmd).getOutcomeListener(); +} else if (cmd instanceof ControlTunnel.SyncCustomMessageSender) { + dataBodies = ((ControlTunnel.SyncCustomMessageSender)cmd).getDataBodies(); + outcomeListener = ((ControlTunnel.SyncCustomMessageSender)cmd).getOutcomeListener(); +} else { + throw new UnsupportedOperationException("Unknown Custom Type control message received"); +} + +DrillBuf reqDrillBuff; +try { + reqDrillBuff = convertToByteBuf(dataBodies); +} catch (Exception ex) { + outcomeListener.failed(new RpcException("Failed to allocate memory while sending request in " + +"LocalControlConnectionManager#convertToByteBuff", ex)); + return; +} finally { + releaseByteBuf(dataBodies); +} + +try { + BitControl.CustomMessage message = (BitControl.CustomMessage) cmd.getMessage(); + final Response response = messageHandler.getHandlerRegistry().handle(message, reqDrillBuff); +
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16474299#comment-16474299 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r187950092 ## File path: exec/rpc/src/main/java/org/apache/drill/exec/rpc/RpcCommand.java ## @@ -17,10 +17,16 @@ */ package org.apache.drill.exec.rpc; +import com.google.protobuf.Internal.EnumLite; import com.google.protobuf.MessageLite; public interface RpcCommand extends RpcConnectionHandler{ Review comment: Space before `{`. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16474293#comment-16474293 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r187963287 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java ## @@ -180,44 +170,38 @@ private void setupNonRootFragments(final Collection fragments) thr foreman.getQueryManager().addFragmentStatusTracker(planFragment, false); if (planFragment.getLeafFragment()) { -updateFragmentCollection(planFragment, localDrillbitEndpoint, localLeafFragmentList, remoteLeafFragmentMap); +leafFragmentMap.put(planFragment.getAssignment(), planFragment); } else { -updateFragmentCollection(planFragment, localDrillbitEndpoint, localIntFragmentList, remoteIntFragmentMap); +intFragmentMap.put(planFragment.getAssignment(), planFragment); } } /* * We need to wait for the intermediates to be sent so that they'll be set up by the time - * the leaves start producing data. We'll use this latch to wait for the responses. + * the leaves start producing data. We'll use this latch to wait for the responses. All the local intermediate + * fragments are submitted locally without creating any actual control connection to itself. * * However, in order not to hang the process if any of the RPC requests fails, we always * count down (see FragmentSubmitFailures), but we count the number of failures so that we'll * know if any submissions did fail. */ -scheduleRemoteIntermediateFragments(remoteIntFragmentMap); - -// Setup local intermediate fragments -for (final PlanFragment fragment : localIntFragmentList) { - startLocalFragment(fragment); -} +scheduleRemoteIntermediateFragments(intFragmentMap); injector.injectChecked(foreman.getQueryContext().getExecutionControls(), "send-fragments", ForemanException.class); /* * Send the remote (leaf) fragments; we don't wait for these. Any problems will come in through - * the regular sendListener event delivery. + * the regular sendListener event delivery˚. All the local leaf fragments are submitted locally without creating + * any actual control connection to itself. */ -for (final DrillbitEndpoint ep : remoteLeafFragmentMap.keySet()) { - sendRemoteFragments(ep, remoteLeafFragmentMap.get(ep), null, null); -} - -// Setup local leaf fragments -for (final PlanFragment fragment : localLeafFragmentList) { - startLocalFragment(fragment); +for (final DrillbitEndpoint ep : leafFragmentMap.keySet()) { + sendRemoteFragments(ep, leafFragmentMap.get(ep), null, null); } } /** - * Send all the remote fragments belonging to a single target drillbit in one request. + * Send all the remote fragments belonging to a single target drillbit in one request. If the assignment Review comment: I think we should consider renaming: `sendRemoteFragments` -> `sendLeafFragments`, `scheduleRemoteIntermediateFragments` -> `scheduleIntermediateFragments`. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16474294#comment-16474294 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r187965870 ## File path: exec/java-exec/src/main/java/org/apache/drill/exec/work/batch/ControlMessageHandler.java ## @@ -254,6 +249,32 @@ private Ack receivingFragmentFinished(final FinishedReceiver finishedReceiver) { return Acks.OK; } + public Ack requestFragmentStatus(FragmentStatus status) { +bee.getContext().getWorkBus().statusUpdate( status); +return Acks.OK; + } + + public Ack requestQueryCancel(QueryId queryId) { +return bee.cancelForeman(queryId, null) ? Acks.OK : Acks.FAIL; + } + + public Ack initializeFragment(InitializeFragments fragments) throws RpcException { +final DrillbitContext drillbitContext = bee.getContext(); +for(int i = 0; i < fragments.getFragmentCount(); i++) { Review comment: Space after for. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16474291#comment-16474291 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r187955446 ## File path: exec/java-exec/src/test/java/org/apache/drill/exec/rpc/control/TestLocalControlConnectionManager.java ## @@ -0,0 +1,304 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.ExecProtos; +import org.apache.drill.exec.proto.GeneralRPCProtos; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.Acks; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.concurrent.CountDownLatch; + +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class TestLocalControlConnectionManager { + + private static final DrillbitEndpoint localEndpoint = DrillbitEndpoint.newBuilder() +.setAddress("10.0.0.1") +.setControlPort(31011) +.setState(DrillbitEndpoint.State.STARTUP) +.build(); + + private static ControlConnectionConfig mockConfig; + + private static ControlMessageHandler mockHandler; + + private static ControlTunnel controlTunnel; + + private CountDownLatch latch; + + private final RpcOutcomeListener outcomeListener = +new RpcOutcomeListener() { +@Override +public void failed(RpcException ex) { + throw new IllegalStateException(ex); +} + +@Override +public void success(GeneralRPCProtos.Ack value, ByteBuf buffer) { + if (value.getOk()) { +latch.countDown(); + } else { +throw new IllegalStateException("Negative Ack received"); + } +} + +@Override +public void interrupted(InterruptedException e) { + Review comment: Why there is no action on interrupted? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16474297#comment-16474297 ] ASF GitHub Bot commented on DRILL-6255: --- arina-ielchiieva commented on a change in pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#discussion_r187955079 ## File path: exec/java-exec/src/test/java/org/apache/drill/exec/rpc/control/TestLocalControlConnectionManager.java ## @@ -0,0 +1,304 @@ +/* + * 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.rpc.control; + +import io.netty.buffer.ByteBuf; +import org.apache.drill.exec.proto.BitControl; +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; +import org.apache.drill.exec.proto.ExecProtos; +import org.apache.drill.exec.proto.GeneralRPCProtos; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.rpc.Acks; +import org.apache.drill.exec.rpc.RpcException; +import org.apache.drill.exec.rpc.RpcOutcomeListener; +import org.apache.drill.exec.work.batch.ControlMessageHandler; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.concurrent.CountDownLatch; + +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class TestLocalControlConnectionManager { + + private static final DrillbitEndpoint localEndpoint = DrillbitEndpoint.newBuilder() +.setAddress("10.0.0.1") +.setControlPort(31011) +.setState(DrillbitEndpoint.State.STARTUP) +.build(); + + private static ControlConnectionConfig mockConfig; + + private static ControlMessageHandler mockHandler; + + private static ControlTunnel controlTunnel; + + private CountDownLatch latch; + + private final RpcOutcomeListener outcomeListener = +new RpcOutcomeListener() { +@Override +public void failed(RpcException ex) { + throw new IllegalStateException(ex); +} + +@Override +public void success(GeneralRPCProtos.Ack value, ByteBuf buffer) { + if (value.getOk()) { +latch.countDown(); + } else { +throw new IllegalStateException("Negative Ack received"); + } +} + +@Override +public void interrupted(InterruptedException e) { + +} + }; + + @BeforeClass + public static void setup() { +mockConfig = mock(ControlConnectionConfig.class); +final ConnectionManagerRegistry registry = new ConnectionManagerRegistry(mockConfig); +registry.setLocalEndpoint(localEndpoint); +ControlConnectionManager manager = registry.getConnectionManager(localEndpoint); +assertTrue(manager instanceof LocalControlConnectionManager); +controlTunnel = new ControlTunnel(manager); + } + + @Before + public void setupForTest() { +mockHandler = mock(ControlMessageHandler.class); +when(mockConfig.getMessageHandler()).thenReturn(mockHandler); + } + + /** + * Verify that SendFragmentStatus is handled correctly using ControlTunnel with LocalControlConnectionManager + */ + @Test + public void testLocalSendFragmentStatus_Success() { +final UserBitShared.QueryId mockQueryId = UserBitShared.QueryId.getDefaultInstance(); +final UserBitShared.QueryProfile mockProfile = UserBitShared.QueryProfile.getDefaultInstance(); +try { Review comment: Why do we need try catch here? And in similar tests below... This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 >
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16467923#comment-16467923 ] Sorabh Hamirwasia commented on DRILL-6255: -- Earlier solution to submit control message doesn't look complete since it was taking care of handling Fragment initialization and status update message from remote fragment only. Other message like UnpauseFragment, CancelFragment, etc was not taken care of. With the current solution all the control channel messages will be taken care to submit it locally rather than over a network channel. A new LocalControlConnectionManager is created for this which is accessed inside ControlTunnel. When a tunnel is created for a Drillbit Endpoint such that it's the local Drillbit then internally it just bypasses the connection creation process and instead submits the request and return the response locally. > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16467914#comment-16467914 ] ASF GitHub Bot commented on DRILL-6255: --- sohami commented on issue #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#issuecomment-387526941 @arina-ielchiieva / @parthchandra - Please help to review this PR. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16467913#comment-16467913 ] ASF GitHub Bot commented on DRILL-6255: --- sohami commented on issue #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253#issuecomment-387526941 @arina-ielchiieva - Please help to review this PR. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (DRILL-6255) Drillbit while sending control message to itself creates a connection instead of submitting locally
[ https://issues.apache.org/jira/browse/DRILL-6255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16467912#comment-16467912 ] ASF GitHub Bot commented on DRILL-6255: --- sohami opened a new pull request #1253: DRILL-6255: Drillbit while sending control message to itself creates … URL: https://github.com/apache/drill/pull/1253 …a connection instead of submitting locally This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drillbit while sending control message to itself creates a connection instead > of submitting locally > --- > > Key: DRILL-6255 > URL: https://issues.apache.org/jira/browse/DRILL-6255 > Project: Apache Drill > Issue Type: Bug > Components: Execution - Flow >Affects Versions: 1.12.0 >Reporter: Sorabh Hamirwasia >Assignee: Sorabh Hamirwasia >Priority: Major > Fix For: 1.14.0 > > > With the new shutdown feature introduced in 1.12, there is a state introduced > in DrillbitEndpoint. Due to this the equality check happening > [here|https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/work/foreman/FragmentsRunner.java#L256] > will result in false and hence the fragments supposed to be scheduled on > Foreman will be treated as remote fragments and a connection will be created > to schedule it. The equality check is false because localEndpoint state is > STARTUP whereas state in assigned Drillbit is ONLINE. > I guess now we should update the equality check to verify just for address > and control port to be same between assigned and local Drillbit endpoint. A > test can be added for this based on _sys.memory_ table since that guarantees > scheduling minor fragments on each Drillbit node. -- This message was sent by Atlassian JIRA (v7.6.3#76005)