summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/service
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/gitblit/service')
-rw-r--r--src/main/java/com/gitblit/service/FederationPullService.java54
-rw-r--r--src/main/java/com/gitblit/service/GarbageCollectorService.java17
-rw-r--r--src/main/java/com/gitblit/service/LuceneService.java39
-rw-r--r--src/main/java/com/gitblit/service/MirrorService.java4
4 files changed, 46 insertions, 68 deletions
diff --git a/src/main/java/com/gitblit/service/FederationPullService.java b/src/main/java/com/gitblit/service/FederationPullService.java
index 629cbf94..3c9f0ed2 100644
--- a/src/main/java/com/gitblit/service/FederationPullService.java
+++ b/src/main/java/com/gitblit/service/FederationPullService.java
@@ -6,7 +6,6 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.InetAddress;
-import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -99,8 +98,7 @@ public abstract class FederationPullService implements Runnable {
FederationPullStatus is = registration.getLowestStatus();
if (is.ordinal() < was.ordinal()) {
// the status for this registration has downgraded
- logger.warn("Federation pull status of {0} is now {1}", registration.name,
- is.name());
+ logger.warn("Federation pull status of {} is now {}", registration.name, is.name());
if (registration.notifyOnError) {
String message = "Federation pull of " + registration.name + " @ "
+ registration.url + " is now at " + is.name();
@@ -110,9 +108,7 @@ public abstract class FederationPullService implements Runnable {
}
}
} catch (Throwable t) {
- logger.error(MessageFormat.format(
- "Failed to pull from federated gitblit ({0} @ {1})", registration.name,
- registration.url), t);
+ logger.error("Failed to pull from federated gitblit ({} @ {})", registration.name, registration.url, t);
} finally {
reschedule(registration);
}
@@ -133,9 +129,8 @@ public abstract class FederationPullService implements Runnable {
// confirm valid characters in server alias
Character c = StringUtils.findInvalidCharacter(registrationFolder);
if (c != null) {
- logger.error(MessageFormat
- .format("Illegal character ''{0}'' in folder name ''{1}'' of federation registration {2}!",
- c, registrationFolder, registration.name));
+ logger.error("Illegal character '{}' in folder name '{}' of federation registration {}!",
+ c, registrationFolder, registration.name);
return;
}
File repositoriesFolder = gitblit.getRepositoriesFolder();
@@ -147,9 +142,8 @@ public abstract class FederationPullService implements Runnable {
String cloneUrl = entry.getKey();
RepositoryModel repository = entry.getValue();
if (!repository.hasCommits) {
- logger.warn(MessageFormat.format(
- "Skipping federated repository {0} from {1} @ {2}. Repository is EMPTY.",
- repository.name, registration.name, registration.url));
+ logger.warn("Skipping federated repository {} from {} @ {}. Repository is EMPTY.",
+ repository.name, registration.name, registration.url);
registration.updateStatus(repository, FederationPullStatus.SKIPPED);
continue;
}
@@ -181,7 +175,7 @@ public abstract class FederationPullService implements Runnable {
Repository existingRepository = gitblit.getRepository(repositoryName);
if (existingRepository == null && gitblit.isCollectingGarbage(repositoryName)) {
- logger.warn(MessageFormat.format("Skipping local repository {0}, busy collecting garbage", repositoryName));
+ logger.warn("Skipping local repository {}, busy collecting garbage", repositoryName);
continue;
}
@@ -196,9 +190,8 @@ public abstract class FederationPullService implements Runnable {
}
existingRepository.close();
if (!origin.startsWith(registration.url)) {
- logger.warn(MessageFormat
- .format("Skipping federated repository {0} from {1} @ {2}. Origin does not match, consider EXCLUDING.",
- repository.name, registration.name, registration.url));
+ logger.warn("Skipping federated repository {} from {} @ {}. Origin does not match, consider EXCLUDING.",
+ repository.name, registration.name, registration.url);
registration.updateStatus(repository, FederationPullStatus.SKIPPED);
continue;
}
@@ -207,8 +200,7 @@ public abstract class FederationPullService implements Runnable {
// clone/pull this repository
CredentialsProvider credentials = new UsernamePasswordCredentialsProvider(
Constants.FEDERATION_USER, registration.token);
- logger.info(MessageFormat.format("Pulling federated repository {0} from {1} @ {2}",
- repository.name, registration.name, registration.url));
+ logger.info("Pulling federated repository {} from {} @ {}", repository.name, registration.name, registration.url);
CloneResult result = JGitUtils.cloneRepository(registrationFolderFile, repository.name,
cloneUrl, registration.bare, credentials);
@@ -220,7 +212,7 @@ public abstract class FederationPullService implements Runnable {
repository.federationStrategy = FederationStrategy.EXCLUDE;
repository.isFrozen = registration.mirror;
repository.showRemoteBranches = !registration.mirror;
- logger.info(MessageFormat.format(" cloning {0}", repository.name));
+ logger.info(" cloning {}", repository.name);
registration.updateStatus(repository, FederationPullStatus.MIRRORED);
} else {
// fetch and update
@@ -240,8 +232,7 @@ public abstract class FederationPullService implements Runnable {
String hash = ref.getReferencedObjectId().getName();
JGitUtils.setBranchRef(r, branch, hash);
- logger.info(MessageFormat.format(" resetting {0} of {1} to {2}", branch,
- repository.name, hash));
+ logger.info(" resetting {} of {} to {}", branch, repository.name, hash);
}
}
@@ -252,8 +243,7 @@ public abstract class FederationPullService implements Runnable {
newHead = repository.HEAD;
}
JGitUtils.setHEADtoRef(r, newHead);
- logger.info(MessageFormat.format(" resetting HEAD of {0} to {1}",
- repository.name, newHead));
+ logger.info(" resetting HEAD of {} to {}", repository.name, newHead);
registration.updateStatus(repository, FederationPullStatus.MIRRORED);
} else {
// indicate no commits pulled
@@ -401,9 +391,7 @@ public abstract class FederationPullService implements Runnable {
} catch (ForbiddenException e) {
// ignore forbidden exceptions
} catch (IOException e) {
- logger.warn(MessageFormat.format(
- "Failed to retrieve USERS from federated gitblit ({0} @ {1})",
- registration.name, registration.url), e);
+ logger.warn("Failed to retrieve USERS from federated gitblit ({} @ {})", registration.name, registration.url, e);
}
try {
@@ -422,9 +410,7 @@ public abstract class FederationPullService implements Runnable {
} catch (ForbiddenException e) {
// ignore forbidden exceptions
} catch (IOException e) {
- logger.warn(MessageFormat.format(
- "Failed to retrieve TEAMS from federated gitblit ({0} @ {1})",
- registration.name, registration.url), e);
+ logger.warn("Failed to retrieve TEAMS from federated gitblit ({} @ {})", registration.name, registration.url, e);
}
try {
@@ -441,9 +427,7 @@ public abstract class FederationPullService implements Runnable {
} catch (ForbiddenException e) {
// ignore forbidden exceptions
} catch (IOException e) {
- logger.warn(MessageFormat.format(
- "Failed to retrieve SETTINGS from federated gitblit ({0} @ {1})",
- registration.name, registration.url), e);
+ logger.warn("Failed to retrieve SETTINGS from federated gitblit ({} @ {})", registration.name, registration.url, e);
}
try {
@@ -463,9 +447,7 @@ public abstract class FederationPullService implements Runnable {
} catch (ForbiddenException e) {
// ignore forbidden exceptions
} catch (IOException e) {
- logger.warn(MessageFormat.format(
- "Failed to retrieve SCRIPTS from federated gitblit ({0} @ {1})",
- registration.name, registration.url), e);
+ logger.warn("Failed to retrieve SCRIPTS from federated gitblit ({} @ {})", registration.name, registration.url, e);
}
}
@@ -487,6 +469,6 @@ public abstract class FederationPullService implements Runnable {
federationName = addr.getHostName();
}
FederationUtils.acknowledgeStatus(addr.getHostAddress(), registration);
- logger.info(MessageFormat.format("Pull status sent to {0}", registration.url));
+ logger.info("Pull status sent to {}", registration.url);
}
} \ No newline at end of file
diff --git a/src/main/java/com/gitblit/service/GarbageCollectorService.java b/src/main/java/com/gitblit/service/GarbageCollectorService.java
index b98560fd..dc095503 100644
--- a/src/main/java/com/gitblit/service/GarbageCollectorService.java
+++ b/src/main/java/com/gitblit/service/GarbageCollectorService.java
@@ -15,7 +15,6 @@
*/
package com.gitblit.service;
-import java.text.MessageFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
@@ -143,7 +142,7 @@ public class GarbageCollectorService implements Runnable {
break;
}
if (isCollectingGarbage(repositoryName)) {
- logger.warn(MessageFormat.format("Already collecting garbage from {0}?!?", repositoryName));
+ logger.warn("Already collecting garbage from {}?!?", repositoryName);
continue;
}
boolean garbageCollected = false;
@@ -153,12 +152,12 @@ public class GarbageCollectorService implements Runnable {
model = repositoryManager.getRepositoryModel(repositoryName);
repository = repositoryManager.getRepository(repositoryName);
if (repository == null) {
- logger.warn(MessageFormat.format("GCExecutor is missing repository {0}?!?", repositoryName));
+ logger.warn("GCExecutor is missing repository {}?!?", repositoryName);
continue;
}
if (!repositoryManager.isIdle(repository)) {
- logger.debug(MessageFormat.format("GCExecutor is skipping {0} because it is not idle", repositoryName));
+ logger.debug("GCExecutor is skipping {} because it is not idle", repositoryName);
continue;
}
@@ -166,11 +165,11 @@ public class GarbageCollectorService implements Runnable {
// disabling *all* access to this repository from Gitblit.
// Think of this as a clutch in a manual transmission vehicle.
if (!setGCStatus(repositoryName, GCStatus.COLLECTING)) {
- logger.warn(MessageFormat.format("Can not acquire GC lock for {0}, skipping", repositoryName));
+ logger.warn("Can not acquire GC lock for {}, skipping", repositoryName);
continue;
}
- logger.debug(MessageFormat.format("GCExecutor locked idle repository {0}", repositoryName));
+ logger.debug("GCExecutor locked idle repository {}", repositoryName);
Git git = new Git(repository);
GarbageCollectCommand gc = git.gc();
@@ -196,7 +195,7 @@ public class GarbageCollectorService implements Runnable {
boolean hasGarbage = sizeOfLooseObjects > 0;
if (hasGarbage && (hasEnoughGarbage || shouldCollectGarbage)) {
long looseKB = sizeOfLooseObjects/1024L;
- logger.info(MessageFormat.format("Collecting {1} KB of loose objects from {0}", repositoryName, looseKB));
+ logger.info("Collecting {} KB of loose objects from {}", looseKB, repositoryName );
// do the deed
gc.call();
@@ -204,7 +203,7 @@ public class GarbageCollectorService implements Runnable {
garbageCollected = true;
}
} catch (Exception e) {
- logger.error("Error collecting garbage in " + repositoryName, e);
+ logger.error("Error collecting garbage in {}", repositoryName, e);
} finally {
// cleanup
if (repository != null) {
@@ -219,7 +218,7 @@ public class GarbageCollectorService implements Runnable {
// reset the GC lock
releaseLock(repositoryName);
- logger.debug(MessageFormat.format("GCExecutor released GC lock for {0}", repositoryName));
+ logger.debug("GCExecutor released GC lock for {}", repositoryName);
}
}
diff --git a/src/main/java/com/gitblit/service/LuceneService.java b/src/main/java/com/gitblit/service/LuceneService.java
index 906a0b5e..2d9fc9f9 100644
--- a/src/main/java/com/gitblit/service/LuceneService.java
+++ b/src/main/java/com/gitblit/service/LuceneService.java
@@ -172,7 +172,7 @@ public class LuceneService implements Runnable {
Repository repository = repositoryManager.getRepository(model.name);
if (repository == null) {
if (repositoryManager.isCollectingGarbage(model.name)) {
- logger.info(MessageFormat.format("Skipping Lucene index of {0}, busy garbage collecting", repositoryName));
+ logger.info("Skipping Lucene index of {}, busy garbage collecting", repositoryName);
}
continue;
}
@@ -200,9 +200,8 @@ public class LuceneService implements Runnable {
if (result.success) {
if (result.commitCount > 0) {
- String msg = "Built {0} Lucene index from {1} commits and {2} files across {3} branches in {4} secs";
- logger.info(MessageFormat.format(msg, model.name, result.commitCount,
- result.blobCount, result.branchCount, result.duration()));
+ logger.info("Built {} Lucene index from {} commits and {} files across {} branches in {} secs",
+ model.name, result.commitCount, result.blobCount, result.branchCount, result.duration());
}
} else {
String msg = "Could not build {0} Lucene index!";
@@ -213,17 +212,15 @@ public class LuceneService implements Runnable {
IndexResult result = updateIndex(model, repository);
if (result.success) {
if (result.commitCount > 0) {
- String msg = "Updated {0} Lucene index with {1} commits and {2} files across {3} branches in {4} secs";
- logger.info(MessageFormat.format(msg, model.name, result.commitCount,
- result.blobCount, result.branchCount, result.duration()));
+ logger.info("Updated {} Lucene index with {} commits and {} files across {} branches in {} secs",
+ model.name, result.commitCount, result.blobCount, result.branchCount, result.duration());
}
} else {
- String msg = "Could not update {0} Lucene index!";
- logger.error(MessageFormat.format(msg, model.name));
+ logger.error("Could not update {} Lucene index!", model.name);
}
}
} catch (Throwable t) {
- logger.error(MessageFormat.format("Lucene indexing failure for {0}", model.name), t);
+ logger.error("Lucene indexing failure for {}", model.name, t);
}
}
@@ -239,7 +236,7 @@ public class LuceneService implements Runnable {
searcher.getIndexReader().close();
}
} catch (Exception e) {
- logger.error("Failed to close index searcher for " + repositoryName, e);
+ logger.error("Failed to close index searcher for {}", repositoryName, e);
}
try {
@@ -248,7 +245,7 @@ public class LuceneService implements Runnable {
writer.close();
}
} catch (Exception e) {
- logger.error("Failed to close index writer for " + repositoryName, e);
+ logger.error("Failed to close index writer for {}", repositoryName, e);
}
}
@@ -262,7 +259,7 @@ public class LuceneService implements Runnable {
try {
writers.get(writer).close();
} catch (Throwable t) {
- logger.error("Failed to close Lucene writer for " + writer, t);
+ logger.error("Failed to close Lucene writer for {}", writer, t);
}
}
writers.clear();
@@ -272,7 +269,7 @@ public class LuceneService implements Runnable {
try {
searchers.get(searcher).getIndexReader().close();
} catch (Throwable t) {
- logger.error("Failed to close Lucene searcher for " + searcher, t);
+ logger.error("Failed to close Lucene searcher for {}", searcher, t);
}
}
searchers.clear();
@@ -594,7 +591,7 @@ public class LuceneService implements Runnable {
resetIndexSearcher(model.name);
result.success();
} catch (Exception e) {
- logger.error("Exception while reindexing " + model.name, e);
+ logger.error("Exception while reindexing {}", model.name, e);
}
return result;
}
@@ -673,7 +670,7 @@ public class LuceneService implements Runnable {
result.commitCount++;
result.success = index(repositoryName, doc);
} catch (Exception e) {
- logger.error(MessageFormat.format("Exception while indexing commit {0} in {1}", commit.getId().getName(), repositoryName), e);
+ logger.error("Exception while indexing commit {} in {}", commit.getId().getName(), repositoryName, e);
}
return result;
}
@@ -701,10 +698,10 @@ public class LuceneService implements Runnable {
writer.commit();
int numDocsAfter = writer.numDocs();
if (numDocsBefore == numDocsAfter) {
- logger.debug(MessageFormat.format("no records found to delete {0}", query.toString()));
+ logger.debug("no records found to delete {}", query.toString());
return false;
} else {
- logger.debug(MessageFormat.format("deleted {0} records with {1}", numDocsBefore - numDocsAfter, query.toString()));
+ logger.debug("deleted {} records with {}", numDocsBefore - numDocsAfter, query.toString());
return true;
}
}
@@ -833,7 +830,7 @@ public class LuceneService implements Runnable {
}
result.success = true;
} catch (Throwable t) {
- logger.error(MessageFormat.format("Exception while updating {0} Lucene index", model.name), t);
+ logger.error("Exception while updating {} Lucene index", model.name, t);
}
return result;
}
@@ -876,7 +873,7 @@ public class LuceneService implements Runnable {
resetIndexSearcher(repositoryName);
return true;
} catch (Exception e) {
- logger.error(MessageFormat.format("Exception while incrementally updating {0} Lucene index", repositoryName), e);
+ logger.error("Exception while incrementally updating {} Lucene index", repositoryName, e);
}
return false;
}
@@ -1049,7 +1046,7 @@ public class LuceneService implements Runnable {
results.add(result);
}
} catch (Exception e) {
- logger.error(MessageFormat.format("Exception while searching for {0}", text), e);
+ logger.error("Exception while searching for {}", text, e);
}
return new ArrayList<SearchResult>(results);
}
diff --git a/src/main/java/com/gitblit/service/MirrorService.java b/src/main/java/com/gitblit/service/MirrorService.java
index eb247fc0..08d54013 100644
--- a/src/main/java/com/gitblit/service/MirrorService.java
+++ b/src/main/java/com/gitblit/service/MirrorService.java
@@ -119,7 +119,7 @@ public class MirrorService implements Runnable {
repository = repositoryManager.getRepository(repositoryName);
if (repository == null) {
- logger.warn(MessageFormat.format("MirrorExecutor is missing repository {0}?!?", repositoryName));
+ logger.warn("MirrorExecutor is missing repository {}?!?", repositoryName);
continue;
}
@@ -204,7 +204,7 @@ public class MirrorService implements Runnable {
}
}
} catch (Exception e) {
- logger.error("Error updating mirror " + repositoryName, e);
+ logger.error("Error updating mirror {}", repositoryName, e);
} finally {
// cleanup
if (repository != null) {