Skip to content

Commit

Permalink
Merge pull request #43281 from ballerina-platform/2201.10.0-stage
Browse files Browse the repository at this point in the history
[2201.10.x] Sync 2201.10.x with the changes from 2201.10.0-stage
  • Loading branch information
gabilang authored Aug 14, 2024
2 parents 5d4ecdb + 9d14866 commit 105b937
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ public interface Repository {
* Get whether remote management is enabled.
* @return True if remote management is enabled, false otherwise.
*/
boolean isRemoteEnabled();
boolean isRemoteManagementEnabled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class RepositoryImpl implements Repository {
private static final String nodeId = generateNodeId();
private static String balHome;
private static String balVersion;
private static boolean isRemoteEnabled = false;
private static boolean isRemoteManagementEnabled = false;

@Override
public List<Artifact> getArtifacts() {
Expand Down Expand Up @@ -73,8 +73,8 @@ public Node getNode() {
}

@Override
public boolean isRemoteEnabled() {
return isRemoteEnabled;
public boolean isRemoteManagementEnabled() {
return isRemoteManagementEnabled;
}

private Artifact createArtifact(ObjectValue service, ObjectValue listener) {
Expand All @@ -92,7 +92,7 @@ private Artifact createArtifact(ObjectValue service, ObjectValue listener) {
}

public static void addServiceListener(BObject listener, BObject service, Object attachPoint) {
if (!isRemoteEnabled) {
if (!isRemoteManagementEnabled) {
return;
}
BServiceType serviceType = (BServiceType) service.getType();
Expand All @@ -101,10 +101,11 @@ public static void addServiceListener(BObject listener, BObject service, Object
listenerServiceMap.put((ObjectValue) listener, (ObjectValue) service);
}

public static void addBallerinaRuntimeInformation(String balHome, String balVersion, boolean isRemoteEnabled) {
public static void addBallerinaRuntimeInformation(String balHome, String balVersion,
boolean isRemoteManagementEnabled) {
RepositoryImpl.balHome = balHome;
RepositoryImpl.balVersion = balVersion;
RepositoryImpl.isRemoteEnabled = isRemoteEnabled;
RepositoryImpl.isRemoteManagementEnabled = isRemoteManagementEnabled;
}

private static String generateNodeId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,6 @@ public class TransactionConstants {

public static final String ANN_NAME_TRX_PARTICIPANT_CONFIG = "Participant";
public static final String TIMESTAMP_OBJECT_VALUE_FIELD = "timeValue";
public static final int DEFAULT_TRX_AUTO_COMMIT_TIMEOUT = 120;
public static final int DEFAULT_TRX_CLEANUP_TIMEOUT = 600;
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
import javax.transaction.xa.Xid;

import static io.ballerina.runtime.api.constants.RuntimeConstants.BALLERINA_BUILTIN_PKG_PREFIX;
import static io.ballerina.runtime.transactions.TransactionConstants.DEFAULT_TRX_AUTO_COMMIT_TIMEOUT;
import static io.ballerina.runtime.transactions.TransactionConstants.DEFAULT_TRX_CLEANUP_TIMEOUT;
import static io.ballerina.runtime.transactions.TransactionConstants.TRANSACTION_PACKAGE_ID;
import static io.ballerina.runtime.transactions.TransactionConstants.TRANSACTION_PACKAGE_NAME;
import static io.ballerina.runtime.transactions.TransactionConstants.TRANSACTION_PACKAGE_VERSION;
Expand All @@ -85,6 +87,8 @@ public class TransactionResourceManager {
private static final String ATOMIKOS_LOG_BASE_PROPERTY = "com.atomikos.icatch.log_base_dir";
private static final String ATOMIKOS_LOG_NAME_PROPERTY = "com.atomikos.icatch.log_base_name";
private static final String ATOMIKOS_REGISTERED_PROPERTY = "com.atomikos.icatch.registered";
public static final String TRANSACTION_AUTO_COMMIT_TIMEOUT_KEY = "transactionAutoCommitTimeout";
public static final String TRANSACTION_CLEANUP_TIMEOUT_KEY = "transactionCleanupTimeout";

private static final Logger log = LoggerFactory.getLogger(TransactionResourceManager.class);
private Map<String, List<BallerinaTransactionContext>> resourceRegistry;
Expand Down Expand Up @@ -187,6 +191,56 @@ private String getTransactionLogDirectory() {
}
}

/**
* This method gets the user specified config for the transaction auto commit timeout. Default is 120.
*
* @return int transaction auto commit timeout value
*/
public static int getTransactionAutoCommitTimeout() {
VariableKey transactionAutoCommitTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID,
TRANSACTION_AUTO_COMMIT_TIMEOUT_KEY, PredefinedTypes.TYPE_INT, false);
if (!ConfigMap.containsKey(transactionAutoCommitTimeoutKey)) {
return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT;
} else {
Object configValue = ConfigMap.get(transactionAutoCommitTimeoutKey);
if (configValue == null) {
return DEFAULT_TRX_AUTO_COMMIT_TIMEOUT;
}
return parseTimeoutValue(configValue, DEFAULT_TRX_AUTO_COMMIT_TIMEOUT);
}
}

/**
* This method gets the user specified config for cleaning up dead transactions. Default is 600.
*
* @return int transaction cleanup after value
*/
public static int getTransactionCleanupTimeout() {
VariableKey transactionCleanupTimeoutKey = new VariableKey(TRANSACTION_PACKAGE_ID,
TRANSACTION_CLEANUP_TIMEOUT_KEY,
PredefinedTypes.TYPE_INT, false);
if (!ConfigMap.containsKey(transactionCleanupTimeoutKey)) {
return DEFAULT_TRX_CLEANUP_TIMEOUT;
} else {
Object configValue = ConfigMap.get(transactionCleanupTimeoutKey);
if (configValue == null) {
return DEFAULT_TRX_CLEANUP_TIMEOUT;
}
return parseTimeoutValue(configValue, DEFAULT_TRX_CLEANUP_TIMEOUT);
}
}

private static int parseTimeoutValue(Object configValue, int defaultValue) {
if (!(configValue instanceof Number number)) {
return defaultValue;
}
int timeoutValue = number.intValue();
if (timeoutValue <= 0) {
return defaultValue;
}
return timeoutValue;
}

/**
* This method will register connection resources with a particular transaction.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"includes": [
{
"pattern": "\\QMETA-INF/axiom.xml\\E"
},
{
"pattern": "resources/.*"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import static io.ballerina.cli.utils.TestUtils.generateTesterinaReports;
import static io.ballerina.projects.util.ProjectConstants.BIN_DIR_NAME;
import static io.ballerina.projects.util.ProjectConstants.TESTS_CACHE_DIR_NAME;
import static io.ballerina.projects.util.ProjectUtils.getResourcesPath;
import static org.ballerinalang.test.runtime.util.TesterinaConstants.CACHE_DIR;
import static org.ballerinalang.test.runtime.util.TesterinaConstants.DOT;
import static org.ballerinalang.test.runtime.util.TesterinaConstants.TESTERINA_TEST_SUITE;
Expand Down Expand Up @@ -370,9 +369,6 @@ private int runTestSuiteWithNativeImage(Package currentPackage, Target target,
nativeArgs.add("-H:Path=" + NativeUtils.convertWinPathToUnixFormat(NativeUtils
.addQuotationMarkToString(nativeTargetPath.toString())));

// Add resources
nativeArgs.add("-H:IncludeResources=" + getResourcesPath());

// native-image configs
nativeArgs.add("-H:ReflectionConfigurationFiles=" + NativeUtils
.convertWinPathToUnixFormat(NativeUtils.addQuotationMarkToString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ SYNOPSIS
[--operations <operation-names>] [-n | --nullable]
[--license] <license-file-path> [--with-tests]
[--client-methods] <resource|remote> [--without-data-binding]
[--status-code-binding]
[--status-code-binding] [--mock] [--with-service-contract]
[--single-file] [--use-sanitized-oas]
bal openapi [-i | --input] <ballerina-service-file-path> [--json]
[-s | --service] <current-service-name>

Expand Down Expand Up @@ -93,6 +94,22 @@ OPTIONS
This option can be used in the client generation to generate the
client methods with status code response binding.

--mock
This option can be used in the client generation to generate a mock
client for the given OpenAPI contract.

--with-service-contract
This option can be used to generate the service contract type for the
given OpenAPI contract.

--single-file
This option can be used to generate the Ballerina service or client
with related types and utility functions in a single file.

--use-sanitized-oas
This is an experimental feature. This option enables service/client code
generation by modifying the given OAS to follow the Ballerina language
best practices.
EXAMPLES
Generate a Ballerina mock service using a `hello.yaml` OpenAPI contract.
$ bal openapi -i hello.yaml --mode service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
import static io.ballerina.projects.util.ProjectConstants.DOT;
import static io.ballerina.projects.util.ProjectConstants.RESOURCE_DIR_NAME;
import static io.ballerina.projects.util.ProjectUtils.getConflictingResourcesMsg;
import static io.ballerina.projects.util.ProjectUtils.getResourcesPath;
import static io.ballerina.projects.util.ProjectUtils.getThinJarFileName;
import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.CLASS_FILE_SUFFIX;

Expand Down Expand Up @@ -724,7 +723,6 @@ private Path emitGraalExecutable(Path executableFilePath, List<Diagnostic> emitR
executableFilePath.toString(),
"-H:Name=" + nativeImageName,
"-H:Path=" + executableFilePath.getParent(),
"-H:IncludeResources=" + getResourcesPath(),
"--no-fallback"));
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ apacheCommonsAxiomImplVersion=1.4.0
apacheCommonsAxiomDomVersion=1.4.0
apacheCommonsAxiomC14nVersion=1.2.22
apacheCommonsCompressVersion=1.26.2
apacheCommonsLang3Version=3.12.0
apacheCommonsLang3Version=3.14.0
apacheCommonsTextVersion=1.10.0
apacheGeronimoStaxVersion=1.0.1
apacheMavenPluginAnnotationsVersion=3.6.0
Expand Down Expand Up @@ -53,7 +53,7 @@ fasterxmlWoodstoxCoreVersion=6.5.0
codehausWoodstoxStax2ApiVersion=4.2.1
commonsBeanutilsVersion=1.9.4
commonsCodecVersion=1.14
commonsIoVersion=2.12.0
commonsIoVersion=2.15.1
commonsLoggingVersion=1.1.1
commonsCollectionsVersion=3.2.2
drongoldTaskTreeVersion=1.3.1
Expand Down Expand Up @@ -135,9 +135,9 @@ sonarqubeGradlePluginVersion=4.0.0.2929
sonarcloudVersion=3.4.0.2513
spullaraMustacheCompilerVersion=0.8.9
squareupOkioVersion=3.4.0
swaggerModelsVersion=2.1.13
swaggerParserVersion=2.0.30
swaggerParserV2Version=2.0.30
swaggerModelsVersion=2.2.22
swaggerParserVersion=2.1.22
swaggerParserV2Version=2.1.22
testngVersion=7.7.0
tongfeiProgressbarVersion=0.7.4
underCouchDownloadVersion=4.0.4
Expand Down
4 changes: 4 additions & 0 deletions langlib/lang.transaction/src/main/ballerina/transaction.bal
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import ballerina/jballerina.java;
configurable boolean managerEnabled = false;
# Config to specify transaction log directory.
configurable string logBase = "transaction_log_dir";
# Config to specify the timeout for auto commit.
configurable int transactionAutoCommitTimeout = 120;
# Config to specify the timeout for cleaning up dead transactions.
configurable int transactionCleanupTimeout = 600;

//TODO: remove this in Beta2 and use an anonymous record instead
# Internally used record to hold information about a transaction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ public static BString getBallerinaNode(Environment env) {
return StringUtils.fromString("balNode-" + node.nodeId);
}

public static void validateIsRemoteEnabled(Environment env) {
public static void validateIsRemoteManagementEnabled(Environment env) {
Repository repository = env.getRepository();
Assert.assertTrue(repository.isRemoteEnabled());
Assert.assertTrue(repository.isRemoteManagementEnabled());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function testListenerFunctionality() {
test:assertTrue(result == ());
test:assertEquals(counter, 3);
validateArtifactCount();
validateIsRemoteEnabled();
validateIsRemoteManagementEnabled();
}

public service class Service {
Expand Down Expand Up @@ -80,6 +80,6 @@ function validateArtifactCount() = @java:Method {
'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.Values"
} external;

function validateIsRemoteEnabled() = @java:Method {
function validateIsRemoteManagementEnabled() = @java:Method {
'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.Values"
} external;

0 comments on commit 105b937

Please sign in to comment.