Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DRILL-2697: Pauses sites wait indefinitely for a resume signal DrillC…
…lient sends a resume signal to UserServer. UserServer triggers a resume call in the correct Foreman. Foreman resumes all pauses related to the query through the Control layer. + Better error messages and more tests in TestDrillbitResilience and TestPauseInjection + Added execution controls to operator context + Removed ControlMessageHandler interface, renamed ControlHandlerImpl to ControlMessageHandler + Added CountDownLatchInjection, useful in cases like ParititionedSender that spawns multiple threads
- Loading branch information
1 parent
4e59633
commit f8e5e61
Showing
34 changed files
with
1,106 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
exec/java-exec/src/main/java/org/apache/drill/exec/testing/CountDownLatchInjection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,51 @@ | |||
/** | |||
* 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.testing; | |||
|
|||
/** | |||
* This class is used internally for tracking injected countdown latches. These latches are specified via | |||
* {@link org.apache.drill.exec.ExecConstants#DRILLBIT_CONTROL_INJECTIONS} session option. | |||
* | |||
* This injection is useful in the case where a thread spawns multiple threads. The parent thread initializes the latch | |||
* with the expected number of countdown and awaits. The child threads count down on the same latch (same site class | |||
* and same descriptor), and once there are enough, the parent thread continues. | |||
*/ | |||
public interface CountDownLatchInjection { | |||
|
|||
/** | |||
* Initializes the underlying latch | |||
* @param count the number of times {@link #countDown} must be invoke before threads can pass through {@link #await} | |||
*/ | |||
void initialize(final int count); | |||
|
|||
/** | |||
* Causes the current thread to wait until the latch has counted down to zero, unless the thread is | |||
* {@link Thread#interrupt interrupted}. | |||
*/ | |||
void await() throws InterruptedException; | |||
|
|||
/** | |||
* Await without interruption. In the case of interruption, log a warning and continue to wait. | |||
*/ | |||
void awaitUninterruptibly(); | |||
|
|||
/** | |||
* Decrements the count of the latch, releasing all waiting threads if the count reaches zero. | |||
*/ | |||
void countDown(); | |||
} |
85 changes: 85 additions & 0 deletions
85
exec/java-exec/src/main/java/org/apache/drill/exec/testing/CountDownLatchInjectionImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,85 @@ | |||
/** | |||
* 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.testing; | |||
|
|||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | |||
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; | |||
import com.fasterxml.jackson.annotation.JsonCreator; | |||
import com.fasterxml.jackson.annotation.JsonProperty; | |||
import com.google.common.base.Preconditions; | |||
import org.apache.drill.common.concurrent.ExtendedLatch; | |||
|
|||
import java.util.concurrent.CountDownLatch; | |||
|
|||
/** | |||
* See {@link org.apache.drill.exec.testing.CountDownLatchInjection} Degenerates to | |||
* {@link org.apache.drill.exec.testing.PauseInjection#pause}, if initialized to zero count. In any case, this injection | |||
* provides more control than PauseInjection. | |||
*/ | |||
@JsonAutoDetect(fieldVisibility = Visibility.ANY) | |||
public class CountDownLatchInjectionImpl extends Injection implements CountDownLatchInjection { | |||
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CountDownLatchInjectionImpl.class); | |||
|
|||
private ExtendedLatch latch = null; | |||
|
|||
@JsonCreator // ensures instances are created only through JSON | |||
private CountDownLatchInjectionImpl(@JsonProperty("address") final String address, | |||
@JsonProperty("port") final int port, | |||
@JsonProperty("siteClass") final String siteClass, | |||
@JsonProperty("desc") final String desc) throws InjectionConfigurationException { | |||
super(address, port, siteClass, desc, 0, 1); | |||
} | |||
|
|||
@Override | |||
protected boolean injectNow() { | |||
return true; | |||
} | |||
|
|||
@Override | |||
public void initialize(final int count) { | |||
Preconditions.checkArgument(latch == null, "Latch can be initialized only once at %s in %s.", desc, | |||
siteClass.getSimpleName()); | |||
Preconditions.checkArgument(count > 0, "Count has to be a positive integer at %s in %s.", desc, | |||
siteClass.getSimpleName()); | |||
latch = new ExtendedLatch(count); | |||
} | |||
|
|||
@Override | |||
public void await() throws InterruptedException { | |||
Preconditions.checkNotNull(latch, "Latch not initialized in %s at %s.", siteClass.getSimpleName(), desc); | |||
try { | |||
latch.await(); | |||
} catch (final InterruptedException e) { | |||
logger.warn("Interrupted while awaiting in %s at %s.", siteClass.getSimpleName(), desc); | |||
throw e; | |||
} | |||
} | |||
|
|||
@Override | |||
public void awaitUninterruptibly() { | |||
Preconditions.checkNotNull(latch, "Latch not initialized in %s at %s.", siteClass.getSimpleName(), desc); | |||
latch.awaitUninterruptibly(); | |||
} | |||
|
|||
@Override | |||
public void countDown() { | |||
Preconditions.checkNotNull(latch, "Latch not initialized in %s at %s.", siteClass.getSimpleName(), desc); | |||
Preconditions.checkArgument(latch.getCount() > 0, "Counting down on latch more than intended."); | |||
latch.countDown(); | |||
} | |||
} |
Oops, something went wrong.