Skip to content
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
11 changes: 0 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<atlasVersion>1.1.8</atlasVersion>
<mockitoVersion>2.22.0</mockitoVersion>
<kerbyVersion>2.1.0</kerbyVersion>
<o11yphantVersion>1.9.2</o11yphantVersion>

<dbImage>postgres:9.4</dbImage>
<hubImage>docker.io/buildchimp/koji-dojo-hub:dev</hubImage>
Expand Down Expand Up @@ -114,12 +113,6 @@
<version>${kerbyVersion}</version>
</dependency>

<!-- metrics support-->
<dependency>
<groupId>org.commonjava.util</groupId>
<artifactId>o11yphant-metrics-api</artifactId>
<version>${o11yphantVersion}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -226,10 +219,6 @@
<artifactId>kerb-client</artifactId>
</dependency>

<dependency>
<groupId>org.commonjava.util</groupId>
<artifactId>o11yphant-metrics-api</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
16 changes: 3 additions & 13 deletions src/main/java/com/redhat/red/build/koji/KojiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.commonjava.atlas.maven.ident.ref.ProjectRef;
import org.commonjava.atlas.maven.ident.ref.ProjectVersionRef;
import org.commonjava.o11yphant.metrics.api.MetricRegistry;
import org.commonjava.rwx.api.RWXMapper;
import org.commonjava.rwx.core.Registry;
import org.commonjava.rwx.error.XmlRpcException;
Expand Down Expand Up @@ -100,8 +99,6 @@ public class KojiClient

private ExecutorService executorService;

private MetricRegistry metricRegistry;

private KojiObjectMapper objectMapper;

private KojiConfig config;
Expand Down Expand Up @@ -164,22 +161,15 @@ private UrlBuilder sessionUrlBuilder( KojiSessionInfo session, Supplier<Map<Stri
};
}

public KojiClient( KojiConfig config, PasswordManager passwordManager, ExecutorService executorService,
MetricRegistry metricRegistry ) throws KojiClientException
public KojiClient( KojiConfig config, PasswordManager passwordManager, ExecutorService executorService )
throws KojiClientException
{
this.config = config;
this.httpFactory = new HttpFactory( passwordManager );
this.executorService = executorService;
this.metricRegistry = metricRegistry;
setup();
}

public KojiClient( KojiConfig config, PasswordManager passwordManager, ExecutorService executorService )
throws KojiClientException
{
this( config, passwordManager, executorService, null );
}

@Override
public synchronized void close()
{
Expand All @@ -203,7 +193,7 @@ public void setup()
logger.debug( "SETUP: Starting KojiClient for: {}", config.getKojiURL() );
try
{
xmlrpcClient = new HC4SyncObjectClient( httpFactory, config.getKojiSiteConfig(), metricRegistry );
xmlrpcClient = new HC4SyncObjectClient( httpFactory, config.getKojiSiteConfig() );
}
catch ( IOException e )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.commonjava.o11yphant.metrics.api.MetricRegistry;
import org.commonjava.o11yphant.metrics.api.Timer;
import org.commonjava.rwx.anno.Request;
import org.commonjava.rwx.api.RWXMapper;
import org.commonjava.rwx.error.XmlRpcException;
Expand All @@ -40,54 +38,26 @@
import java.net.MalformedURLException;
import java.util.Arrays;

import static org.commonjava.o11yphant.metrics.util.NameUtils.name;

public class HC4SyncObjectClient
{
private final HttpFactory httpFactory;

private final SiteConfig siteConfig;

private final MetricRegistry metricRegistry;

private final String[] extraPath;

public HC4SyncObjectClient( final HttpFactory httpFactory, final SiteConfig siteConfig,
final MetricRegistry metricRegistry, String... extraPath )
String... extraPath )
{
this.httpFactory = httpFactory;
this.siteConfig = siteConfig;
this.metricRegistry = metricRegistry;
this.extraPath = extraPath;
}

public <T> T call( final Object request, final Class<T> responseType, final UrlBuilder urlBuilder,
final RequestModifier requestModifier ) throws XmlRpcException
{
if ( metricRegistry == null )
{
return RetryUtils.withRetry( () -> doCall( request, responseType, urlBuilder, requestModifier ) );
}

// Apply global and per request metric

try ( final Timer.Context timerContext = metricRegistry.timer( name( getClass(), "call" ) ).time();
final Timer.Context requestTimerContext = metricRegistry.timer( name( request.getClass(), "call" ) ).time() )
{
try
{
return RetryUtils.withRetry( () -> doCall( request, responseType, urlBuilder, requestModifier ) );
}
finally
{
timerContext.stop();
requestTimerContext.stop();
}
}
catch ( Exception e )
{
throw new XmlRpcException( e.getMessage(), e );
}
return RetryUtils.withRetry( () -> doCall( request, responseType, urlBuilder, requestModifier ) );
}

private <T> T doCall( final Object request, final Class<T> responseType, final UrlBuilder urlBuilder,
Expand Down
Loading