X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-node%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fnode%2FDelivery.java;h=59318563dc77da20e46c889434b0f1e8a92ff6e7;hb=adb2ad2d16e851fbf8dcc71af68949a74463204d;hp=150d2aa2673b31ffd9e9b5933cd5a1b9f8aa07d9;hpb=8f28bfe406b657c924440dcee6e3d7b302ce639c;p=dmaap%2Fdatarouter.git diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java index 150d2aa2..59318563 100644 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/Delivery.java @@ -26,6 +26,8 @@ package org.onap.dmaap.datarouter.node; 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.HashMap; @@ -64,7 +66,6 @@ public class Delivery { this.config = config; Runnable cmon = this::checkconfig; config.registerConfigTask(cmon); - checkconfig(); } /** @@ -98,12 +99,16 @@ public class Delivery { 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() { @@ -126,20 +131,20 @@ public class Delivery { 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() { @@ -161,7 +166,13 @@ public class Delivery { cleardir(sxbase + "/" + sxdir + "/" + sdir); } } - sxf.delete(); // won't if anything still in it + try { + if (sxf.list().length == 0) { + Files.delete(sxf.toPath()); // won't if anything still in it + } + } catch (IOException e) { + logger.error("Failed to delete file: " + sxf.getPath(), e); + } } } @@ -203,7 +214,7 @@ public class Delivery { }).start(); } nextcheck = 0; - notify(); + notifyAll(); } private void dodelivery() { @@ -225,7 +236,7 @@ public class Delivery { continue; } nextcheck = 0; - notify(); + notifyAll(); return (dq); } long now = System.currentTimeMillis(); @@ -248,17 +259,17 @@ public class Delivery { 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; } } @@ -302,7 +313,7 @@ public class Delivery { } DelItem delItem = (DelItem) object; return Objects.equals(pubid, delItem.pubid) - && Objects.equals(getSpool(), delItem.getSpool()); + && Objects.equals(getSpool(), delItem.getSpool()); } @Override