Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[MRESOLVER-440] Clean up transport names and config keys #375

Merged
merged 26 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public String getArtifactUpdatePolicy() {
* @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
* @see RepositoryPolicy#UPDATE_POLICY_DAILY
* @see RepositoryPolicy#UPDATE_POLICY_NEVER
* @since TBD
* @since 2.0.0
*/
public DefaultRepositorySystemSession setArtifactUpdatePolicy(String artifactUpdatePolicy) {
verifyStateForMutation();
Expand All @@ -341,7 +341,7 @@ public String getMetadataUpdatePolicy() {
* @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
* @see RepositoryPolicy#UPDATE_POLICY_DAILY
* @see RepositoryPolicy#UPDATE_POLICY_NEVER
* @since TBD
* @since 2.0.0
*/
public DefaultRepositorySystemSession setMetadataUpdatePolicy(String metadataUpdatePolicy) {
verifyStateForMutation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ DependencyResult resolveDependencies(RepositorySystemSession session, Dependency
* @param session The repository session, must not be {@code null}.
* @param root The dependency node root of the graph, must not be {@code null}.
* @return The flattened list of dependency nodes, never {@code null}.
* @since TBD
* @since 2.0.0
*/
List<DependencyNode> flattenDependencyNodes(RepositorySystemSession session, DependencyNode root);

Expand Down Expand Up @@ -301,7 +301,7 @@ List<RemoteRepository> newResolutionRepositories(
* associated with its creator {@link RepositorySystem} instance, and may be used only with that given instance and
* only within the lifespan of it, and after use should be closed.
*
* @since TBD
* @since 2.0.0
*/
RepositorySystemSession.SessionBuilder createSessionBuilder();

Expand All @@ -322,7 +322,7 @@ List<RemoteRepository> newResolutionRepositories(
/**
* Closes this instance, invokes {@link #shutdown()}.
*
* @since TBD
* @since 2.0.0
*/
@Override
default void close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public interface RepositorySystemSession {
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*
* @since TBD
* @since 2.0.0
*/
interface CloseableSession extends RepositorySystemSession, Closeable {
/**
Expand Down Expand Up @@ -104,7 +104,7 @@ interface CloseableSession extends RepositorySystemSession, Closeable {
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*
* @since TBD
* @since 2.0.0
*/
interface SessionBuilder {
/**
Expand Down Expand Up @@ -185,7 +185,7 @@ interface SessionBuilder {
* @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
* @see RepositoryPolicy#UPDATE_POLICY_DAILY
* @see RepositoryPolicy#UPDATE_POLICY_NEVER
* @since TBD
* @since 2.0.0
*/
SessionBuilder setArtifactUpdatePolicy(String artifactUpdatePolicy);

Expand All @@ -198,7 +198,7 @@ interface SessionBuilder {
* @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
* @see RepositoryPolicy#UPDATE_POLICY_DAILY
* @see RepositoryPolicy#UPDATE_POLICY_NEVER
* @since TBD
* @since 2.0.0
*/
SessionBuilder setMetadataUpdatePolicy(String metadataUpdatePolicy);

Expand Down Expand Up @@ -535,7 +535,7 @@ interface SessionBuilder {
* @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
* @see RepositoryPolicy#UPDATE_POLICY_DAILY
* @see RepositoryPolicy#UPDATE_POLICY_NEVER
* @since TBD
* @since 2.0.0
*/
String getArtifactUpdatePolicy();

Expand All @@ -547,7 +547,7 @@ interface SessionBuilder {
* @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
* @see RepositoryPolicy#UPDATE_POLICY_DAILY
* @see RepositoryPolicy#UPDATE_POLICY_NEVER
* @since TBD
* @since 2.0.0
*/
String getMetadataUpdatePolicy();

Expand Down Expand Up @@ -715,7 +715,7 @@ interface SessionBuilder {
*
* @param handler the handler, never {@code null}.
* @return {@code true} if handler successfully registered, {@code false} otherwise.
* @since TBD
* @since 2.0.0
*/
boolean addOnSessionEndedHandler(Runnable handler);
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public RepositoryPolicy(boolean enabled, String updatePolicy, String checksumPol
* @param metadataUpdatePolicy The update interval after which locally cached metadata from the repository is considered stale
* and should be re-fetched, may be {@code null}.
* @param checksumPolicy The way checksum verification should be handled, may be {@code null}.
* @since TBD
* @since 2.0.0
*/
public RepositoryPolicy(
boolean enabled, String artifactUpdatePolicy, String metadataUpdatePolicy, String checksumPolicy) {
Expand Down Expand Up @@ -128,7 +128,7 @@ public String getUpdatePolicy() {
* Gets the update policy for locally cached artifacts from the repository.
*
* @return The update policy, never {@code null}.
* @since TBD
* @since 2.0.0
*/
public String getArtifactUpdatePolicy() {
return artifactUpdatePolicy;
Expand All @@ -138,7 +138,7 @@ public String getArtifactUpdatePolicy() {
* Gets the update policy for locally cached metadata from the repository.
*
* @return The update policy, never {@code null}.
* @since TBD
* @since 2.0.0
*/
public String getMetadataUpdatePolicy() {
return metadataUpdatePolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public DependencyResult setCollectExceptions(List<Exception> exceptions) {
* Gets the resolution results for the dependency nodes that matched {@link DependencyRequest#getFilter()}.
*
* @return The resolution results for the dependency nodes, never {@code null}.
* @since TBD
* @since 2.0.0
*/
public List<DependencyNode> getDependencyNodeResults() {
return dependencyNodeResults;
Expand All @@ -156,7 +156,7 @@ public List<DependencyNode> getDependencyNodeResults() {
*
* @param results The resolution results for the dependency nodes, may be {@code null}.
* @return This result for chaining, never {@code null}.
* @since TBD
* @since 2.0.0
*/
public DependencyResult setDependencyNodeResults(List<DependencyNode> results) {
if (results == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;

import org.eclipse.aether.ConfigurationProperties;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.RequestTrace;
import org.eclipse.aether.metadata.Metadata;
Expand Down Expand Up @@ -67,18 +66,19 @@
import org.slf4j.LoggerFactory;

import static java.util.Objects.requireNonNull;
import static org.eclipse.aether.connector.basic.BasicRepositoryConnectorConfigurationKeys.CONFIG_PROP_PARALLEL_PUT;
import static org.eclipse.aether.connector.basic.BasicRepositoryConnectorConfigurationKeys.CONFIG_PROP_PERSISTED_CHECKSUMS;
import static org.eclipse.aether.connector.basic.BasicRepositoryConnectorConfigurationKeys.CONFIG_PROP_SMART_CHECKSUMS;
import static org.eclipse.aether.connector.basic.BasicRepositoryConnectorConfigurationKeys.CONFIG_PROP_THREADS;
import static org.eclipse.aether.connector.basic.BasicRepositoryConnectorConfigurationKeys.DEFAULT_PARALLEL_PUT;
import static org.eclipse.aether.connector.basic.BasicRepositoryConnectorConfigurationKeys.DEFAULT_PERSISTED_CHECKSUMS;
import static org.eclipse.aether.connector.basic.BasicRepositoryConnectorConfigurationKeys.DEFAULT_SMART_CHECKSUMS;
import static org.eclipse.aether.connector.basic.BasicRepositoryConnectorConfigurationKeys.DEFAULT_THREADS;

/**
*
*/
final class BasicRepositoryConnector implements RepositoryConnector {

private static final String CONFIG_PROP_THREADS = "aether.connector.basic.threads";

private static final String CONFIG_PROP_SMART_CHECKSUMS = "aether.connector.smartChecksums";

private static final String CONFIG_PROP_PARALLEL_PUT = "aether.connector.basic.parallelPut";

private static final Logger LOGGER = LoggerFactory.getLogger(BasicRepositoryConnector.class);

private final Map<String, ProvidedChecksumsSource> providedChecksumsSources;
Expand Down Expand Up @@ -134,14 +134,15 @@ final class BasicRepositoryConnector implements RepositoryConnector {
this.providedChecksumsSources = providedChecksumsSources;
this.closed = new AtomicBoolean(false);

maxThreads = ExecutorUtils.threadCount(session, 5, CONFIG_PROP_THREADS, "maven.artifact.threads");
smartChecksums = ConfigUtils.getBoolean(session, true, CONFIG_PROP_SMART_CHECKSUMS);
maxThreads = ExecutorUtils.threadCount(session, DEFAULT_THREADS, CONFIG_PROP_THREADS);
smartChecksums = ConfigUtils.getBoolean(session, DEFAULT_SMART_CHECKSUMS, CONFIG_PROP_SMART_CHECKSUMS);
parallelPut = ConfigUtils.getBoolean(
session, true, CONFIG_PROP_PARALLEL_PUT + "." + repository.getId(), CONFIG_PROP_PARALLEL_PUT);
persistedChecksums = ConfigUtils.getBoolean(
session,
ConfigurationProperties.DEFAULT_PERSISTED_CHECKSUMS,
ConfigurationProperties.PERSISTED_CHECKSUMS);
DEFAULT_PARALLEL_PUT,
CONFIG_PROP_PARALLEL_PUT + "." + repository.getId(),
CONFIG_PROP_PARALLEL_PUT);
persistedChecksums =
ConfigUtils.getBoolean(session, DEFAULT_PERSISTED_CHECKSUMS, CONFIG_PROP_PERSISTED_CHECKSUMS);
}

private Executor getExecutor(int tasks) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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.eclipse.aether.connector.basic;

import org.eclipse.aether.ConfigurationProperties;
import org.eclipse.aether.RepositorySystemSession;

/**
* The configuration keys for {@link BasicRepositoryConnector}.
*
* @since 2.0.0
*/
public final class BasicRepositoryConnectorConfigurationKeys {
private BasicRepositoryConnectorConfigurationKeys() {}

/**
* The prefix for configuration properties.
*/
public static final String CONFIG_PROPS_PREFIX =
ConfigurationProperties.PREFIX_CONNECTOR + BasicRepositoryConnectorFactory.NAME + ".";

/**
* Flag indicating whether checksums which are retrieved during checksum validation should be persisted in the
* local repository next to the file they provide the checksum for.
*
* @since 0.9.0.M4
* @configurationSource {@link RepositorySystemSession#getConfigProperties()}
* @configurationType {@link java.lang.Boolean}
* @configurationDefaultValue {@link #DEFAULT_PERSISTED_CHECKSUMS}
* @configurationRepoIdSuffix No
*/
public static final String CONFIG_PROP_PERSISTED_CHECKSUMS = CONFIG_PROPS_PREFIX + "persistedChecksums";

public static final boolean DEFAULT_PERSISTED_CHECKSUMS = true;

/**
* Flag indicating whether checksums which are retrieved during checksum validation should be persisted in the
* local repository next to the file they provide the checksum for.
*
* @since 0.9.0.M4
* @configurationSource {@link RepositorySystemSession#getConfigProperties()}
* @configurationType {@link java.lang.Integer}
* @configurationDefaultValue {@link #DEFAULT_THREADS}
* @configurationRepoIdSuffix No
*/
public static final String CONFIG_PROP_THREADS = CONFIG_PROPS_PREFIX + "threads";

public static final int DEFAULT_THREADS = 5;

/**
* Enables or disables parallel PUT processing (parallel deploys) on basic connector globally or per remote
* repository. When disabled, connector behaves exactly as in Maven 3.8.x did: GETs are parallel while PUTs
* are sequential.
*
* @since 1.9.5
* @configurationSource {@link RepositorySystemSession#getConfigProperties()}
* @configurationType {@link java.lang.Boolean}
* @configurationDefaultValue {@link #DEFAULT_PARALLEL_PUT}
* @configurationRepoIdSuffix Yes
*/
public static final String CONFIG_PROP_PARALLEL_PUT = CONFIG_PROPS_PREFIX + "parallelPut";

public static final boolean DEFAULT_PARALLEL_PUT = true;

/**
* Flag indicating that instead of comparing the external checksum fetched from the remote repo with the
* calculated one, it should try to extract the reference checksum from the actual artifact response headers
* This only works for HTTP transports.
*
* @since 0.9.0.M3
* @configurationSource {@link RepositorySystemSession#getConfigProperties()}
* @configurationType {@link java.lang.Boolean}
* @configurationDefaultValue {@link #DEFAULT_SMART_CHECKSUMS}
* @configurationRepoIdSuffix No
*/
public static final String CONFIG_PROP_SMART_CHECKSUMS = CONFIG_PROPS_PREFIX + "smartChecksums";

public static final boolean DEFAULT_SMART_CHECKSUMS = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface RepositorySystemLifecycle {
* <p>
* <em>Same session instance can be started only once.</em>
*
* @since TBD
* @since 2.0.0
*/
void sessionStarted(CloseableSession session);

Expand All @@ -58,7 +58,7 @@ public interface RepositorySystemLifecycle {
* <p>
* <em>Same session instance can be ended only once.</em>
*
* @since TBD
* @since 2.0.0
*/
void sessionEnded(CloseableSession session);

Expand All @@ -67,7 +67,7 @@ public interface RepositorySystemLifecycle {
* <p>
* Throws if session was not passed to {@link #sessionStarted(CloseableSession)} beforehand.
*
* @since TBD
* @since 2.0.0
*/
void addOnSessionEndedHandle(CloseableSession session, Runnable handler);
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public UpdateCheck<T, E> setFileValid(boolean fileValid) {
*
* @return The policy to use for the artifact check.
* @see org.eclipse.aether.repository.RepositoryPolicy
* @since TBD
* @since 2.0.0
*/
public String getArtifactPolicy() {
return artifactPolicy;
Expand All @@ -164,7 +164,7 @@ public String getArtifactPolicy() {
*
* @return The policy to use for the metadata check.
* @see org.eclipse.aether.repository.RepositoryPolicy
* @since TBD
* @since 2.0.0
*/
public String getMetadataPolicy() {
return metadataPolicy;
Expand All @@ -176,7 +176,7 @@ public String getMetadataPolicy() {
* @param artifactPolicy The policy to use for the artifact check, may be {@code null}.
* @return This object for chaining.
* @see org.eclipse.aether.repository.RepositoryPolicy
* @since TBD
* @since 2.0.0
*/
public UpdateCheck<T, E> setArtifactPolicy(String artifactPolicy) {
this.artifactPolicy = artifactPolicy;
Expand All @@ -189,7 +189,7 @@ public UpdateCheck<T, E> setArtifactPolicy(String artifactPolicy) {
* @param metadataPolicy The policy to use for the metadata check, may be {@code null}.
* @return This object for chaining.
* @see org.eclipse.aether.repository.RepositoryPolicy
* @since TBD
* @since 2.0.0
*/
public UpdateCheck<T, E> setMetadataPolicy(String metadataPolicy) {
this.metadataPolicy = metadataPolicy;
Expand Down
Loading