forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#27312] fix(JmsIO): create a session pool for JmsIO apache#27312
[apache#26203] fix(JmsIO): use a unused port for tests in JmsIO apache#26203 Fixes apache#27312, apache#26203 Co-Authored-By: Amrane Ait Zeouay <122456352+amranezeRenault@users.noreply.github.com>
- Loading branch information
1 parent
04fdf08
commit 55cb703
Showing
13 changed files
with
665 additions
and
166 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
70 changes: 70 additions & 0 deletions
70
sdks/java/io/jms/src/main/java/org/apache/beam/sdk/io/jms/pool/JmsPoolConfiguration.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* 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.beam.sdk.io.jms.pool; | ||
|
||
import static org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkArgument; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import java.io.Serializable; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
import org.joda.time.Duration; | ||
|
||
@AutoValue | ||
public abstract class JmsPoolConfiguration implements Serializable { | ||
private static final Integer DEFAULT_MAX_ACTIVE_CONNECTIONS = 100; | ||
private static final Integer DEFAULT_INITIAL_ACTIVE_CONNECTIONS = 20; | ||
private static final Duration DEFAULT_MAX_TIMEOUT_DURATION = Duration.standardMinutes(5); | ||
|
||
abstract int getMaxActiveConnections(); | ||
|
||
public abstract int getInitialActiveConnections(); | ||
|
||
public abstract Duration getMaxTimeout(); | ||
|
||
public static JmsPoolConfiguration create() { | ||
return create(DEFAULT_MAX_ACTIVE_CONNECTIONS, DEFAULT_INITIAL_ACTIVE_CONNECTIONS, null); | ||
} | ||
|
||
public static JmsPoolConfiguration create( | ||
int maxActiveConnections, int initialActiveConnections, @Nullable Duration maxTimeout) { | ||
checkArgument(maxActiveConnections > 0, "maxActiveConnections should be greater than 0"); | ||
checkArgument( | ||
initialActiveConnections > 0, "initialActiveConnections should be greater than 0"); | ||
|
||
if (maxTimeout == null || maxTimeout.equals(Duration.ZERO)) { | ||
maxTimeout = DEFAULT_MAX_TIMEOUT_DURATION; | ||
} | ||
|
||
return new AutoValue_JmsPoolConfiguration.Builder() | ||
.setMaxActiveConnections(maxActiveConnections) | ||
.setInitialActiveConnections(initialActiveConnections) | ||
.setMaxTimeout(maxTimeout) | ||
.build(); | ||
} | ||
|
||
@AutoValue.Builder | ||
abstract static class Builder { | ||
abstract JmsPoolConfiguration.Builder setMaxActiveConnections(int maxActiveConnections); | ||
|
||
abstract JmsPoolConfiguration.Builder setInitialActiveConnections(int initialActiveConnections); | ||
|
||
abstract JmsPoolConfiguration.Builder setMaxTimeout(Duration maxTimeout); | ||
|
||
abstract JmsPoolConfiguration build(); | ||
} | ||
} |
Oops, something went wrong.