import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Hashtable;
+import java.util.HashMap;
import java.util.Objects;
/**
private int threads;
private int curthreads;
private NodeConfigManager config;
- private Hashtable<String, DeliveryQueue> dqs = new Hashtable<>();
+ private HashMap<String, DeliveryQueue> dqs = new HashMap<>();
private DeliveryQueue[] queues = new DeliveryQueue[0];
private int qpos = 0;
private long nextcheck;
return;
}
File fdir = new File(dir);
- for (File junk : fdir.listFiles()) {
- if (junk.isFile()) {
- junk.delete();
+ try {
+ for (File junk : fdir.listFiles()) {
+ if (junk.isFile()) {
+ Files.delete(fdir.toPath());
+ }
}
+ Files.delete(fdir.toPath());
+ } catch (IOException e) {
+ logger.error("Failed to delete file: " + fdir.getPath(), e);
}
- fdir.delete();
}
private void freeDiskCheck() {
DelItem[] items = cv.toArray(new DelItem[cv.size()]);
Arrays.sort(items);
long stop = (long) (tspace * fdstop);
- logger.info(
- "NODE0501 Free disk space below red threshold. current=" + cur + " red=" + start + TOTAL + tspace);
+ logger.warn(
+ "NODE0501 Free disk space below red threshold. current=" + cur + " red=" + start + TOTAL + tspace);
if (determineFreeDiskSpace(spoolfile, tspace, stop, cur, items)) {
return;
}
cur = spoolfile.getUsableSpace();
if (cur >= stop) {
- logger.info("NODE0503 Free disk space at or above yellow threshold. current=" + cur + YELLOW + stop
- + TOTAL + tspace);
+ logger.warn("NODE0503 Free disk space at or above yellow threshold. current=" + cur + YELLOW + stop
+ + TOTAL + tspace);
return;
}
logger.warn(
- "NODE0504 Unable to recover sufficient disk space to reach green status. current=" + cur + YELLOW
- + stop + TOTAL + tspace);
+ "NODE0504 Unable to recover sufficient disk space to reach green status. current=" + cur + YELLOW
+ + stop + TOTAL + tspace);
}
private void cleardirs() {
cleardir(sxbase + "/" + sxdir + "/" + sdir);
}
}
- sxf.delete(); // won't if anything still in it
+ try {
+ Files.delete(sxf.toPath()); // won't if anything still in it
+ } catch (IOException e) {
+ logger.error("Failed to delete file: " + sxf.getPath(), e);
+ }
}
}
DestInfo[] alldis = config.getAllDests();
DeliveryQueue[] nqs = new DeliveryQueue[alldis.length];
qpos = 0;
- Hashtable<String, DeliveryQueue> ndqs = new Hashtable<>();
+ HashMap<String, DeliveryQueue> ndqs = new HashMap<>();
for (DestInfo di : alldis) {
String spl = di.getSpool();
DeliveryQueue dq = dqs.get(spl);
cleardirs();
while (curthreads < threads) {
curthreads++;
- (new Thread("Delivery Thread") {
+ (new Thread("del-thread-" + curthreads) {
@Override
public void run() {
dodelivery();
}).start();
}
nextcheck = 0;
- notify();
+ notifyAll();
}
private void dodelivery() {
continue;
}
nextcheck = 0;
- notify();
+ notifyAll();
return (dq);
}
long now = System.currentTimeMillis();
private boolean determineFreeDiskSpace(File spoolfile, long tspace, long stop, long cur, DelItem[] items) {
for (DelItem item : items) {
long amount = dqs.get(item.getSpool()).cancelTask(item.getPublishId());
- logger.info("NODE0502 Attempting to discard " + item.getSpool() + "/" + item.getPublishId()
- + " to free up disk");
+ logger.debug("NODE0502 Attempting to discard " + item.getSpool() + "/" + item.getPublishId()
+ + " to free up disk");
if (amount > 0) {
cur += amount;
if (cur >= stop) {
cur = spoolfile.getUsableSpace();
}
if (cur >= stop) {
- logger.info(
- "NODE0503 Free disk space at or above yellow threshold. current=" + cur + YELLOW + stop
- + TOTAL + tspace);
+ logger.warn(
+ "NODE0503 Free disk space at or above yellow threshold. current=" + cur + YELLOW + stop
+ + TOTAL + tspace);
return true;
}
}
return false;
}
- private static class DelItem implements Comparable<DelItem> {
+ static class DelItem implements Comparable<DelItem> {
private String pubid;
private String spool;
}
DelItem delItem = (DelItem) object;
return Objects.equals(pubid, delItem.pubid)
- && Objects.equals(getSpool(), delItem.getSpool());
+ && Objects.equals(getSpool(), delItem.getSpool());
}
@Override