Skip to content

Commit

Permalink
Tone down logging noise on maven indexer plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
davsclaus committed Nov 28, 2013
1 parent c2e9b9a commit b7c6ec7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 58 deletions.
Expand Up @@ -3,7 +3,7 @@
import org.codehaus.plexus.util.StringUtils;

/**
* Represents information about an artefact in a repository
* Represents information about an artifact in a repository
*/
public class ArtifactDTO {
private final String groupId;
Expand Down
@@ -1,31 +1,11 @@
/**
*
* 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 io.hawt.maven.indexer;

import io.hawt.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.management.InstanceNotFoundException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.io.IOException;
import java.util.Arrays;
import java.util.Timer;
import java.util.TimerTask;
Expand All @@ -50,18 +30,18 @@ public void init() {
@Override
public void run() {
try {
LOG.info("Starting to create the MavenIndexerFacade");
LOG.debug("Starting to create the MavenIndexerFacade");
createMavenIndexer();
LOG.info("Completed creating the MavenIndexerFacade");
LOG.debug("Completed creating the MavenIndexerFacade");
} catch (Exception e) {
LOG.error("Failed to create the MavenIndexerFacade: " + e, e);
}
}
};
timer.schedule(task, 3000);
LOG.info("Started the async timer to create the MavenIndexerFacade after the application starts up");
LOG.debug("Started the async timer to create the MavenIndexerFacade after the application starts up");
if (repositories != null) {
LOG.info("Using remote repositories: " + Arrays.asList(repositories));
LOG.debug("Using remote repositories: " + Arrays.asList(repositories));
}
}

Expand Down
Expand Up @@ -40,16 +40,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
Expand Down Expand Up @@ -145,40 +137,48 @@ public void init() throws Exception {
}

public void downloadOrUpdateIndices() throws IOException {
LOG.info("Updating the maven indices. This may take a while, please be patient...");
Set<Map.Entry<String, IndexingContext>> entries = indexContexts.entrySet();

if (!entries.isEmpty()) {
LOG.info("Updating the maven indices. This may take a while, please be patient...");
}

for (Map.Entry<String, IndexingContext> entry : entries) {
final String contextId = entry.getKey();
IndexingContext context = entry.getValue();
Date contextTime = context.getTimestamp();

TransferListener listener = new AbstractTransferListener() {
public void transferStarted(TransferEvent transferEvent) {
LOG.info(contextId + ": Downloading " + transferEvent.getResource().getName());
LOG.debug(contextId + ": Downloading " + transferEvent.getResource().getName());
}

public void transferProgress(TransferEvent transferEvent, byte[] buffer, int length) {
}

public void transferCompleted(TransferEvent transferEvent) {
LOG.info(contextId + ": Download complete");
LOG.debug(contextId + ": Download complete");
}
};
ResourceFetcher resourceFetcher = new WagonHelper.WagonFetcher(httpWagon, listener, null, null);

IndexUpdateRequest updateRequest = new IndexUpdateRequest(context, resourceFetcher);
IndexUpdateResult updateResult = indexUpdater.fetchAndUpdateIndex(updateRequest);
if (updateResult.isFullUpdate()) {
LOG.info(contextId + ": Full index update completed on index");
LOG.debug(contextId + ": Full index update completed on index");
} else {
Date timestamp = updateResult.getTimestamp();
if (timestamp != null && timestamp.equals(contextTime)) {
LOG.info(contextId + ": No index update needed, index is up to date!");
LOG.debug(contextId + ": No index update needed, index is up to date!");
} else {
LOG.info(contextId + ": Incremental update happened, change covered " + contextTime + " - " + timestamp + " period.");
LOG.debug(contextId + ": Incremental update happened, change covered " + contextTime + " - " + timestamp + " period.");
}
}
}

if (!entries.isEmpty()) {
LOG.info("Completed updating {} maven indices.", entries.size());
}
}

public void destroy() throws Exception {
Expand Down
@@ -1,24 +1,5 @@
/**
*
* 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 io.hawt.maven.indexer;

import org.apache.lucene.search.BooleanQuery;

import java.io.IOException;
import java.util.List;

Expand Down

0 comments on commit b7c6ec7

Please sign in to comment.