diff --git a/build.properties b/build.properties index 65f691264..91cca9971 100644 --- a/build.properties +++ b/build.properties @@ -4,7 +4,6 @@ javacTarget=1.8 # Release Configuration releaseVersion=1.925 -releaseNr=9749 releaseFileParentDir=yacy privateKeyFile=private.key diff --git a/build.xml b/build.xml index c42d3935c..52b1e3572 100644 --- a/build.xml +++ b/build.xml @@ -90,28 +90,27 @@ - - - - - - - - - - - - - - - - - - - - + + - + + + + + + + + + + + + + + + + + + @@ -120,13 +119,23 @@ - - - - - - + + + + + + + + + + + + + + + + @@ -518,8 +527,8 @@ - + @@ -535,7 +544,7 @@ - + diff --git a/defaults/yacyBuild.properties.template b/defaults/yacyBuild.properties.template index 10eaa3f6e..5b0e09234 100644 --- a/defaults/yacyBuild.properties.template +++ b/defaults/yacyBuild.properties.template @@ -1,3 +1,7 @@ -SVNRevision = @REPL_REVISION_NR@ Version = @REPL_VERSION@ -RepositoryVersion = @REPL_REPVER@ \ No newline at end of file +RepositoryVersionDate = @REPL_REPVERDATE@ +RepositoryVersionTime = @REPL_REPVERTIME@ +RepositoryVersionHash = @REPL_REPVERHASH@ +ReleaseStub = @REPL_RELEASESTUB@ +dstamp = @REPL_DSTAMP@ +tstamp = @REPL_TSTAMP@ \ No newline at end of file diff --git a/htroot/api/version.xml b/htroot/api/version.xml index b0585f62c..ab78a3ebb 100644 --- a/htroot/api/version.xml +++ b/htroot/api/version.xml @@ -1,6 +1,9 @@ - #[versionstring]# - #[svnRev]# - 19700101 + #[versionstring]# + #[buildDate]# + #[buildTime]# + #[buildDateTime]# + #[buildDateTime]# + #[buildVersion]# diff --git a/source/net/yacy/htroot/ConfigUpdate_p.java b/source/net/yacy/htroot/ConfigUpdate_p.java index 506d9e7f0..867432f18 100644 --- a/source/net/yacy/htroot/ConfigUpdate_p.java +++ b/source/net/yacy/htroot/ConfigUpdate_p.java @@ -78,26 +78,26 @@ public class ConfigUpdate_p { final String release = post.get("releasedownload", ""); if (!release.isEmpty()) { try { - yacyRelease versionToDownload = new yacyRelease(new DigestURL(release)); + yacyRelease versionToDownload = new yacyRelease(new DigestURL(release)); - // replace this version with version which contains public key - final yacyRelease.DevAndMainVersions allReleases = yacyRelease.allReleases(false, false); - final Set mostReleases = versionToDownload.isMainRelease() ? allReleases.main : allReleases.dev; - for (final yacyRelease rel : mostReleases) { - if (rel.equals(versionToDownload)) { - versionToDownload = rel; - break; - } - } - final File downloadedRelease = versionToDownload.downloadRelease(); - if(downloadedRelease == null) { - prop.put("candeploy_downloadError", "1"); - prop.putHTML("candeploy_downloadError_releasedownload", release); - } + // replace this version with version which contains public key + final yacyRelease.DevAndMainVersions allReleases = yacyRelease.allReleases(false, false); + final Set mostReleases = versionToDownload.isMainRelease() ? allReleases.main : allReleases.dev; + for (final yacyRelease rel : mostReleases) { + if (rel.equals(versionToDownload)) { + versionToDownload = rel; + break; + } + } + final File downloadedRelease = versionToDownload.downloadRelease(); + if(downloadedRelease == null) { + prop.put("candeploy_downloadError", "1"); + prop.putHTML("candeploy_downloadError_releasedownload", release); + } } catch (final IOException e) { - ConcurrentLog.logException(e); - prop.put("candeploy_downloadError", "1"); - prop.putHTML("candeploy_downloadError_releasedownload", release); + ConcurrentLog.logException(e); + prop.put("candeploy_downloadError", "1"); + prop.putHTML("candeploy_downloadError_releasedownload", release); } } } @@ -112,8 +112,8 @@ public class ConfigUpdate_p { try { // only delete files from RELEASE directory if (FileUtils.isInDirectory(new File(sb.releasePath, release), sb.releasePath)) { - FileUtils.deletedelete(new File(sb.releasePath, release)); - FileUtils.deletedelete(new File(sb.releasePath, release + ".sig")); + FileUtils.deletedelete(new File(sb.releasePath, release)); + FileUtils.deletedelete(new File(sb.releasePath, release + ".sig")); } else { sb.getLog().severe("AUTO-UPDATE: could not delete " + release + ": file not in release directory."); } @@ -141,9 +141,9 @@ public class ConfigUpdate_p { prop.put("candeploy_autoUpdate", "4"); } else { if(yacyRelease.deployRelease(downloaded)) { - sb.terminate(10, "manual release update to " + downloaded.getName()); - sb.getLog().info("AUTO-UPDATE: deploy and restart initiated"); - prop.put("candeploy_autoUpdate", "1"); + sb.terminate(10, "manual release update to " + downloaded.getName()); + sb.getLog().info("AUTO-UPDATE: deploy and restart initiated"); + prop.put("candeploy_autoUpdate", "1"); } else { sb.getLog().info("AUTO-UPDATE: omitting update because an error occurred while trying to deploy the release.."); prop.put("candeploy_autoUpdate", "5"); @@ -163,7 +163,7 @@ public class ConfigUpdate_p { } // version information - final String versionstring = yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision(); + final String versionstring = yacyBuildProperties.getReleaseStub(); prop.putHTML("candeploy_versionpp", versionstring); final boolean devenvironment = new File(sb.getAppPath(), ".git").exists(); float thisVersion = Float.parseFloat(yacyBuildProperties.getVersion()); @@ -180,14 +180,14 @@ public class ConfigUpdate_p { prop.put("candeploy_deployenabled", (downloadedFilesNum == 0) ? "0" : ((devenvironment) ? "1" : "2")); // prevent that a developer-version is over-deployed - final NavigableSet downloadedReleases = new TreeSet(); + final NavigableSet downloadedReleases = new TreeSet<>(); for (final File downloaded : downloadedFiles) { try { final yacyRelease release = new yacyRelease(downloaded); downloadedReleases.add(release); } catch (final RuntimeException e) { // not a valid release - // can be also a restart- or deploy-file + // can be also a restart- or deploy-file final File invalid = downloaded; if (!(invalid.getName().endsWith(".bat") || invalid.getName().endsWith(".sh") || invalid.getName().endsWith(".sig"))) { // Windows & Linux don't like deleted scripts while execution! invalid.deleteOnExit(); @@ -216,7 +216,7 @@ public class ConfigUpdate_p { final yacyRelease.DevAndMainVersions releasess = yacyRelease.allReleases(false, false); relcount = 0; - final ArrayList rlist = new ArrayList(); + final ArrayList rlist = new ArrayList<>(); final Set remoteDevReleases = releasess.dev; remoteDevReleases.removeAll(downloadedReleases); for (final yacyRelease release : remoteDevReleases) { diff --git a/source/net/yacy/htroot/Status.java b/source/net/yacy/htroot/Status.java index dede1e48e..ba394466f 100644 --- a/source/net/yacy/htroot/Status.java +++ b/source/net/yacy/htroot/Status.java @@ -58,9 +58,9 @@ public class Status private static final String PEERSTATUS = "peerStatus"; public static serverObjects respond( - final RequestHeader header, - final serverObjects post, - final serverSwitch env) { + final RequestHeader header, + final serverObjects post, + final serverSwitch env) { // return variable that accumulates replacements final serverObjects prop = new serverObjects(); final Switchboard sb = (Switchboard) env; @@ -77,7 +77,7 @@ public class Status if ( post != null && !post.isEmpty() ) { if ( sb.adminAuthenticated(header) < 2 ) { - prop.authenticationRequired(); + prop.authenticationRequired(); return prop; } boolean redirect = false; @@ -133,7 +133,7 @@ public class Status // password protection if ( (sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").isEmpty()) - && (!sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false)) ) { + && (!sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false)) ) { prop.put("protection", "0"); // not protected prop.put("urgentSetPassword", "1"); } else { @@ -143,8 +143,8 @@ public class Status if ( sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false) ) { prop.put("unrestrictedLocalAccess", 1); if(sb.getConfig(SwitchboardConstants.SERVER_SERVLETS_CALLED, "").indexOf("ConfigAccounts_p.html", 0) < 0) { - /* Encourage checking accounts config page to be sure that unrestricted local access is desired */ - prop.put("warningUnrestrictedLocalAccess", true); + /* Encourage checking accounts config page to be sure that unrestricted local access is desired */ + prop.put("warningUnrestrictedLocalAccess", true); } } @@ -157,7 +157,7 @@ public class Status } if ( !sb.observer.getMemoryAvailable() ) { final String minFree = - Formatter.bytesToString(sb.observer.getMinFreeMemory() * 1024L * 1024L); + Formatter.bytesToString(sb.observer.getMinFreeMemory() * 1024L * 1024L); prop.put("warningMemoryLow", "1"); prop.put("warningMemoryLow_minSpace", minFree); } @@ -166,7 +166,7 @@ public class Status // version information //final String versionstring = yacyVersion.combined2prettyVersion(sb.getConfig("version","0.1")); - final String versionstring = yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision(); + final String versionstring = yacyBuildProperties.getReleaseStub(); prop.put("versionpp", versionstring); prop.put("java.version", System.getProperty("java.version")); @@ -239,18 +239,18 @@ public class Status } } final String peerStatus = - ((sb.peers.mySeed() == null) ? Seed.PEERTYPE_VIRGIN : sb.peers.mySeed().get( - Seed.PEERTYPE, - Seed.PEERTYPE_VIRGIN)); + ((sb.peers.mySeed() == null) ? Seed.PEERTYPE_VIRGIN : sb.peers.mySeed().get( + Seed.PEERTYPE, + Seed.PEERTYPE_VIRGIN)); if ( Seed.PEERTYPE_VIRGIN.equals(peerStatus) - && "freeworld".equals(sb.getConfig(SwitchboardConstants.NETWORK_NAME, "")) - && !SwitchboardConstants.CLUSTER_MODE_PRIVATE_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, ""))) { + && "freeworld".equals(sb.getConfig(SwitchboardConstants.NETWORK_NAME, "")) + && !SwitchboardConstants.CLUSTER_MODE_PRIVATE_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, ""))) { prop.put(PEERSTATUS, "0"); prop.put("urgentStatusVirgin", "1"); } else if ( Seed.PEERTYPE_JUNIOR.equals(peerStatus) - && "freeworld".equals(sb.getConfig(SwitchboardConstants.NETWORK_NAME, "")) - && !SwitchboardConstants.CLUSTER_MODE_PRIVATE_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, ""))) { + && "freeworld".equals(sb.getConfig(SwitchboardConstants.NETWORK_NAME, "")) + && !SwitchboardConstants.CLUSTER_MODE_PRIVATE_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, ""))) { prop.put(PEERSTATUS, "1"); prop.put("warningStatusJunior", "1"); } else if ( Seed.PEERTYPE_SENIOR.equals(peerStatus) ) { @@ -266,9 +266,9 @@ public class Status final String seedUploadMethod = sb.getConfig("seedUploadMethod", ""); if ( !"none".equalsIgnoreCase(seedUploadMethod) - || ("".equals(seedUploadMethod) && (sb.getConfig("seedFTPPassword", "").length() > 0 || sb - .getConfig("seedFilePath", "") - .length() > 0)) ) { + || ("".equals(seedUploadMethod) && (sb.getConfig("seedFTPPassword", "").length() > 0 || sb + .getConfig("seedFilePath", "") + .length() > 0)) ) { if ( "".equals(seedUploadMethod) ) { if ( sb.getConfig("seedFTPPassword", "").length() > 0 ) { sb.setConfig("seedUploadMethod", "Ftp"); @@ -289,8 +289,8 @@ public class Status prop.putHTML("seedServer_seedFile", sb.getConfig("seedFilePath", "")); } prop.put( - "seedServer_lastUpload", - PeerActions.formatInterval(System.currentTimeMillis() - sb.peers.lastSeedUpload_timeStamp)); + "seedServer_lastUpload", + PeerActions.formatInterval(System.currentTimeMillis() - sb.peers.lastSeedUpload_timeStamp)); } else { prop.put(SEEDSERVER, "0"); // disabled } @@ -347,18 +347,18 @@ public class Status prop.put("loaderQueuePercent", (loaderPercent > 100) ? 100 : loaderPercent); prop.putNum("localCrawlQueueSize", sb - .getThread(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL) - .getJobCount()); + .getThread(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL) + .getJobCount()); prop.put("localCrawlPaused", sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL) - ? "1" - : "0"); + ? "1" + : "0"); prop.putNum( - "remoteTriggeredCrawlQueueSize", - sb.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) != null ? sb.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount() : 0); + "remoteTriggeredCrawlQueueSize", + sb.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) != null ? sb.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount() : 0); prop.put( - "remoteTriggeredCrawlPaused", - sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) ? "1" : "0"); + "remoteTriggeredCrawlPaused", + sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) ? "1" : "0"); prop.putNum("stackCrawlQueueSize", sb.crawlStacker.size()); diff --git a/source/net/yacy/htroot/api/version.java b/source/net/yacy/htroot/api/version.java index dd7833db5..04bee4e64 100644 --- a/source/net/yacy/htroot/api/version.java +++ b/source/net/yacy/htroot/api/version.java @@ -12,9 +12,12 @@ public class version { public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) { // return variable that accumulates replacements final serverObjects prop = new serverObjects(); - - prop.put("versionstring", yacyBuildProperties.getLongVersion()); - prop.put("svnRev", yacyBuildProperties.getSVNRevision()); + prop.put("versionstring", yacyBuildProperties.getReleaseStub()); + prop.put("buildDate", yacyBuildProperties.getRepositoryVersionDate()); + prop.put("buildTime", yacyBuildProperties.getRepositoryVersionTime()); + prop.put("buildDateTime", yacyBuildProperties.getRepositoryVersionDate() + yacyBuildProperties.getRepositoryVersionTime()); + prop.put("buildHash", yacyBuildProperties.getRepositoryVersionHash()); + prop.put("buildVersion", yacyBuildProperties.getVersion()); // return rewrite properties return prop; diff --git a/source/net/yacy/kelondro/logging/ThreadDump.java b/source/net/yacy/kelondro/logging/ThreadDump.java index 9f1f24eaa..6233e0b21 100644 --- a/source/net/yacy/kelondro/logging/ThreadDump.java +++ b/source/net/yacy/kelondro/logging/ThreadDump.java @@ -57,8 +57,8 @@ public class ThreadDump extends HashMap> imp private static final Pattern multiDumpFilterPattern = Pattern.compile(multiDumpFilter); public static class StackTrace { - private String text; - private Thread.State state; + private final String text; + private final Thread.State state; public StackTrace(final String text, final Thread.State state) { this.state = state; this.text = text; @@ -81,7 +81,7 @@ public class ThreadDump extends HashMap> imp } public static class Lock { - private String id; + private final String id; public Lock(final String name) { this.id = name; } @@ -122,7 +122,7 @@ public class ThreadDump extends HashMap> imp /** * Try to get the thread dump from a yacy.log file which is available when YaCy is started with - * startYACY.sh -l + * startYACY.sh -l * @param logFile the log file to read * @throws IOException when a read/write error occurred */ @@ -145,10 +145,10 @@ public class ThreadDump extends HashMap> imp if (sizeAfter <= sizeBefore) return; try(final RandomAccessFile raf = new RandomAccessFile(logFile, "r");) { - raf.seek(sizeBefore); - final byte[] b = new byte[(int) (sizeAfter - sizeBefore)]; - raf.readFully(b); - + raf.seek(sizeBefore); + final byte[] b = new byte[(int) (sizeAfter - sizeBefore)]; + raf.readFully(b); + // import the thread dump; importText(new ByteArrayInputStream(b)); } @@ -179,7 +179,7 @@ public class ThreadDump extends HashMap> imp String line; String thread = null; int p; - List list = new ArrayList(); + List list = new ArrayList<>(); Thread.State state = null; Thread.State state0; while ((line = br.readLine()) != null) { @@ -189,7 +189,7 @@ public class ThreadDump extends HashMap> imp if (thread != null) { put(new ThreadDump.StackTrace(thread, state), list); } - list = new ArrayList(); + list = new ArrayList<>(); thread = null; state = null; continue; @@ -262,7 +262,7 @@ public class ThreadDump extends HashMap> imp final String threaddump = sb.toString(); @SuppressWarnings("unlikely-arg-type") List threads = get(threaddump); - if (threads == null) threads = new ArrayList(); + if (threads == null) threads = new ArrayList<>(); Thread.State state = null; for (final String t: threads) { final int p = t.indexOf(statestatement); @@ -303,8 +303,8 @@ public class ThreadDump extends HashMap> imp for (int i = size() + 10; i > 0; i--) { for (final Map.Entry entry: locks.entrySet()) { if (entry.getValue().intValue() == i) { - bufferappend(buffer, plain, "holds lock for " + i + " threads:"); - final List list = get(entry.getKey()); + bufferappend(buffer, plain, "holds lock for " + i + " threads:"); + final List list = get(entry.getKey()); if (list == null) continue; bufferappend(buffer, plain, "Thread= " + entry.getKey()); for (final String s: list) bufferappend(buffer, plain, " " + (plain ? s : s.replaceAll("<", "<").replaceAll(">", ">"))); @@ -323,7 +323,7 @@ public class ThreadDump extends HashMap> imp final boolean plain) { // collect single dumps - final Map dumps = new HashMap(); + final Map dumps = new HashMap<>(); ThreadDump x; for (final Map trace: stackTraces) { x = new ThreadDump(rootPath, trace, plain, Thread.State.RUNNABLE); @@ -384,7 +384,7 @@ public class ThreadDump extends HashMap> imp public List>> freerun() { - final List>> runner = new ArrayList>>(); + final List>> runner = new ArrayList<>(); runf: for (final Map.Entry> entry: entrySet()) { // check if the thread is locked or holds a lock if (entry.getKey().state != Thread.State.RUNNABLE) continue runf; @@ -402,7 +402,7 @@ public class ThreadDump extends HashMap> imp */ public Map locks() { int p; - final Map locks = new HashMap(); + final Map locks = new HashMap<>(); for (final Map.Entry> entry: entrySet()) { for (final String s: entry.getValue()) { if ((p = s.indexOf("locked <",0)) > 0) { @@ -433,7 +433,7 @@ public class ThreadDump extends HashMap> imp public Map countLocks() { final Map locks = locks(); - final Map count = new HashMap(); + final Map count = new HashMap<>(); for (final Map.Entry entry: locks.entrySet()) { // look where the lock has an effect int c = 0; @@ -461,8 +461,8 @@ public class ThreadDump extends HashMap> imp if (sleep > 0) try {Thread.sleep(sleep);} catch (final InterruptedException e) {} // Thread dump final Date dt = new Date(); - final String versionstring = yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision(); - Runtime runtime = Runtime.getRuntime(); + final String versionstring = yacyBuildProperties.getReleaseStub(); + final Runtime runtime = Runtime.getRuntime(); ThreadDump.bufferappend(buffer, plain, "************* Start Thread Dump " + dt + " *******************"); ThreadDump.bufferappend(buffer, plain, " "); @@ -473,9 +473,9 @@ public class ThreadDump extends HashMap> imp ThreadDump.bufferappend(buffer, plain, " "); ThreadDump.bufferappend(buffer, plain, " "); - File appPath = sb.getAppPath(); + final File appPath = sb.getAppPath(); if (multiple) { - final ArrayList> traces = new ArrayList>(); + final ArrayList> traces = new ArrayList<>(); for (int i = 0; i < multipleCount; i++) { try { traces.add(ThreadDump.getAllStackTraces()); @@ -486,7 +486,7 @@ public class ThreadDump extends HashMap> imp ThreadDump.appendStackTraceStats(appPath, buffer, traces, plain); } else { // write a thread dump to standard error output - File logFile = new File("yacy.log"); + final File logFile = new File("yacy.log"); if (ThreadDump.canProduceLockedBy(logFile)) { try { new ThreadDump(logFile).appendBlockTraces(buffer, plain); @@ -511,10 +511,10 @@ public class ThreadDump extends HashMap> imp ThreadDump.bufferappend(buffer, plain, "************* End Thread Dump " + dt + " *******************"); ThreadDump.bufferappend(buffer, plain, ""); - ThreadMXBean threadbean = ManagementFactory.getThreadMXBean(); + final ThreadMXBean threadbean = ManagementFactory.getThreadMXBean(); ThreadDump.bufferappend(buffer, plain, "Thread list from ThreadMXBean, " + threadbean.getThreadCount() + " threads:"); - ThreadInfo[] threadinfo = threadbean.dumpAllThreads(true, true); - for (ThreadInfo ti: threadinfo) { + final ThreadInfo[] threadinfo = threadbean.dumpAllThreads(true, true); + for (final ThreadInfo ti: threadinfo) { ThreadDump.bufferappend(buffer, plain, ti.getThreadName()); } diff --git a/source/net/yacy/peers/operation/yacyBuildProperties.java b/source/net/yacy/peers/operation/yacyBuildProperties.java index a4b21cec9..e95c70aba 100644 --- a/source/net/yacy/peers/operation/yacyBuildProperties.java +++ b/source/net/yacy/peers/operation/yacyBuildProperties.java @@ -2,39 +2,51 @@ package net.yacy.peers.operation; import java.io.FileInputStream; import java.io.IOException; -import java.util.Locale; import java.util.Properties; import java.util.regex.Pattern; public final class yacyBuildProperties { - + private static Properties props = new Properties(); - + static { try { props.load(new FileInputStream("defaults/yacyBuild.properties")); - } catch (IOException e) { - e.printStackTrace(); + } catch (final IOException e) { + e.printStackTrace(); props = null; } } - public static String getSVNRevision() { - if (props == null) return "0"; - final String revision = props.getProperty("SVNRevision"); - return revision.contains("@") || revision.contains("$") ? "0" : revision; + public static String getVersion() { + return props.getProperty("Version", "0.1"); } - public static String getVersion() { - if (props == null) return "0.1"; - final String version = props.getProperty("Version"); - return version.contains("@") ? "0.1" : version; + public static String getRepositoryVersionDate() { + return props.getProperty("RepositoryVersionDate", "20220101"); + } + + public static String getRepositoryVersionTime() { + return props.getProperty("RepositoryVersionTime", "0000"); + } + + public static String getRepositoryVersionHash() { + return props.getProperty("RepositoryVersionHash", "0"); + } + + public static String getReleaseStub() { + return props.getProperty("ReleaseStub", "yacy_v0.1_202201010000_000000000"); } - public static final Pattern versionMatcher = Pattern.compile("\\A(\\d+\\.\\d{1,3})(\\d{0,5})\\z"); - - public static String getLongVersion() { - return String.format(Locale.US, "%.3f%05d", Float.valueOf(getVersion()), Integer.valueOf(getSVNRevision())); + public static String getDstamp() { + return props.getProperty("dstamp", "20220101"); } + + public static String getTstamp() { + return props.getProperty("tstamp", "0000"); + } + + public static final Pattern versionMatcher = Pattern.compile("\\A(\\d+\\.\\d{1,3})(\\d{0,5})\\z"); + } diff --git a/source/net/yacy/peers/operation/yacyVersion.java b/source/net/yacy/peers/operation/yacyVersion.java index 97d40ae43..b65bf4f85 100644 --- a/source/net/yacy/peers/operation/yacyVersion.java +++ b/source/net/yacy/peers/operation/yacyVersion.java @@ -79,10 +79,7 @@ public class yacyVersion implements Comparator, Comparable, Comparable, Comparable -*
  • one single instance of the plasmaSwitchboard is generated, which itself -* starts a thread with a plasmaHTMLCache object. This object simply counts -* files sizes in the cache and terminates them. It also generates a -* plasmaCrawlerLoader object, which may itself start some more httpc-calling -* threads to load web pages. They terminate automatically when a page has -* loaded. -*
  • one serverCore - thread is started, which implements a multi-threaded -* server. The process may start itself many more processes that handle -* connections.lo -*
  • finally, all idle-dependent processes are written in a queue in -* plasmaSwitchboard which are worked off inside an idle-sensitive loop of the -* main process. (here) -* -* -* On termination, the following must be done: -*
      -*
    • stop feeding of the crawling process because it otherwise fills the -* indexing queue. -*
    • say goodbye to connected peers and disable new connections. Don't wait for -* success. -*
    • first terminate the serverCore thread. This prevents that new cache -* objects are queued. -*
    • wait that the plasmaHTMLCache terminates (it should be normal that this -* process already has terminated). -*
    • then wait for termination of all loader process of the -* plasmaCrawlerLoader. -*
    • work off the indexing and cache storage queue. These values are inside a -* RAM cache and would be lost otherwise. -*
    • write all settings. -*
    • terminate. -*
    -*/ + * This is the main class of YaCy. Several threads are started from here: + *
      + *
    • one single instance of the plasmaSwitchboard is generated, which itself + * starts a thread with a plasmaHTMLCache object. This object simply counts + * files sizes in the cache and terminates them. It also generates a + * plasmaCrawlerLoader object, which may itself start some more httpc-calling + * threads to load web pages. They terminate automatically when a page has + * loaded. + *
    • one serverCore - thread is started, which implements a multi-threaded + * server. The process may start itself many more processes that handle + * connections.lo + *
    • finally, all idle-dependent processes are written in a queue in + * plasmaSwitchboard which are worked off inside an idle-sensitive loop of the + * main process. (here) + *
    + * + * On termination, the following must be done: + *
      + *
    • stop feeding of the crawling process because it otherwise fills the + * indexing queue. + *
    • say goodbye to connected peers and disable new connections. Don't wait for + * success. + *
    • first terminate the serverCore thread. This prevents that new cache + * objects are queued. + *
    • wait that the plasmaHTMLCache terminates (it should be normal that this + * process already has terminated). + *
    • then wait for termination of all loader process of the + * plasmaCrawlerLoader. + *
    • work off the indexing and cache storage queue. These values are inside a + * RAM cache and would be lost otherwise. + *
    • write all settings. + *
    • terminate. + *
    + */ public final class yacy { @@ -139,12 +139,12 @@ public final class yacy { private static Switchboard sb = null; /** - * Starts up the whole application. Sets up all datastructures and starts - * the main threads. - * - * @param homePath Root-path where all information is to be found. - * @param startupFree free memory at startup time, to be used later for statistics - */ + * Starts up the whole application. Sets up all datastructures and starts + * the main threads. + * + * @param homePath Root-path where all information is to be found. + * @param startupFree free memory at startup time, to be used later for statistics + */ private static void startup(final File dataHome, final File appHome, final long startupMemFree, final long startupMemTotal, final boolean gui) { String tmpdir=null; try { @@ -185,7 +185,7 @@ public final class yacy { System.out.println("could not find logging properties in homePath=" + dataHome); ConcurrentLog.logException(e); } - ConcurrentLog.config("STARTUP", "YaCy version: " + yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision()); + ConcurrentLog.config("STARTUP", "YaCy version: " + yacyBuildProperties.getReleaseStub()); ConcurrentLog.config("STARTUP", "Java version: " + System.getProperty("java.version", "no-java-version")); ConcurrentLog.config("STARTUP", "Operation system: " + System.getProperty("os.name","unknown")); ConcurrentLog.config("STARTUP", "Application root-path: " + appHome); @@ -235,7 +235,7 @@ public final class yacy { if (oldRev > 1) { oldVer = Double.parseDouble(tmpversion) + oldRev / 100000000.0; } else { - oldVer = Double.parseDouble(yacyBuildProperties.getLongVersion()); // failsafe (assume current version = no migration) + oldVer = Double.parseDouble(yacyBuildProperties.getVersion()); // failsafe (assume current version = no migration) } } else { oldVer = Double.parseDouble(tmpversion); @@ -243,8 +243,8 @@ public final class yacy { } catch (final NumberFormatException e) { oldVer = 0.0d; } - final double newRev = Double.parseDouble(yacyBuildProperties.getLongVersion()); - sb.setConfig(Seed.VERSION, yacyBuildProperties.getLongVersion()); + final double newRev = Double.parseDouble(yacyBuildProperties.getVersion()); + sb.setConfig(Seed.VERSION, yacyBuildProperties.getVersion()); sb.setConfig("applicationRoot", appHome.toString()); sb.setConfig("dataRoot", dataHome.toString()); @@ -262,16 +262,16 @@ public final class yacy { final File htdocsReadme = new File(htDocsPath, "readme.txt"); if (!(htdocsReadme.exists())) try {FileUtils.copy(( "This is your root directory for individual Web Content\r\n" + - "\r\n" + - "Please place your html files into the www subdirectory.\r\n" + - "The URL of that path is either\r\n" + - "http://www..yacy or\r\n" + - "http://:/www\r\n" + - "\r\n" + - "Other subdirectories may be created; they map to corresponding sub-domains.\r\n" + - "This directory shares it's content with the applications htroot path, so you\r\n" + - "may access your yacy search page with\r\n" + - "http://.yacy/\r\n" + + "\r\n" + + "Please place your html files into the www subdirectory.\r\n" + + "The URL of that path is either\r\n" + + "http://www..yacy or\r\n" + + "http://:/www\r\n" + + "\r\n" + + "Other subdirectories may be created; they map to corresponding sub-domains.\r\n" + + "This directory shares it's content with the applications htroot path, so you\r\n" + + "may access your yacy search page with\r\n" + + "http://.yacy/\r\n" + "\r\n").getBytes(), htdocsReadme);} catch (final IOException e) { System.out.println("Error creating htdocs readme: " + e.getMessage()); } @@ -314,7 +314,7 @@ public final class yacy { Browser.openBrowser(("http://localhost:"+port) + "/" + browserPopUpPage); } }.start(); - // Browser.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage); + // Browser.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage); } catch (final Throwable e) { // cannot open browser. This may be normal in headless environments //Log.logException(e); @@ -377,11 +377,11 @@ public final class yacy { // save information about available memory after all initializations //try { - sb.setConfig("memoryFreeAfterInitBGC", MemoryControl.free()); - sb.setConfig("memoryTotalAfterInitBGC", MemoryControl.total()); - System.gc(); - sb.setConfig("memoryFreeAfterInitAGC", MemoryControl.free()); - sb.setConfig("memoryTotalAfterInitAGC", MemoryControl.total()); + sb.setConfig("memoryFreeAfterInitBGC", MemoryControl.free()); + sb.setConfig("memoryTotalAfterInitBGC", MemoryControl.total()); + System.gc(); + sb.setConfig("memoryFreeAfterInitAGC", MemoryControl.free()); + sb.setConfig("memoryTotalAfterInitAGC", MemoryControl.total()); //} catch (final ConcurrentModificationException e) {} // wait for server shutdown @@ -446,15 +446,15 @@ public final class yacy { } /** - * Loads the configuration from the data-folder. - * FIXME: Why is this called over and over again from every method, instead - * of setting the configurationdata once for this class in main? - * - * @param mes Where are we called from, so that the errormessages can be - * more descriptive. - * @param homePath Root-path where all the information is to be found. - * @return Properties read from the configurationfile. - */ + * Loads the configuration from the data-folder. + * FIXME: Why is this called over and over again from every method, instead + * of setting the configurationdata once for this class in main? + * + * @param mes Where are we called from, so that the errormessages can be + * more descriptive. + * @param homePath Root-path where all the information is to be found. + * @return Properties read from the configurationfile. + */ private static Properties configuration(final String mes, final File homePath) { ConcurrentLog.config(mes, "Application Root Path: " + homePath.toString()); @@ -490,11 +490,11 @@ public final class yacy { } /** - * Call the shutdown-page of YaCy to tell it to shut down. This method is - * called if you start yacy with the argument -shutdown. - * - * @param homePath Root-path where all the information is to be found. - */ + * Call the shutdown-page of YaCy to tell it to shut down. This method is + * called if you start yacy with the argument -shutdown. + * + * @param homePath Root-path where all the information is to be found. + */ public static void shutdown(final File homePath) { // start up System.out.println(copyright); @@ -773,51 +773,51 @@ public final class yacy { // show yacy version System.out.println(copyright); } else if ((args.length > 1) && (args[0].toLowerCase(Locale.ROOT).equals("-config"))) { - // set config parameter. Special handling of adminAccount=user:pwd (generates md5 encoded password) - // on Windows parameter should be enclosed in doublequotes to accept = sign (e.g. -config "port=8090" "port.ssl=8043") - final File f = new File (dataRoot,"DATA/SETTINGS/"); - if (!f.exists()) { - mkdirsIfNeseccary(f); - } else { - if (new File(dataRoot, "DATA/yacy.running").exists()) { - System.out.println("please restart YaCy"); - } + // set config parameter. Special handling of adminAccount=user:pwd (generates md5 encoded password) + // on Windows parameter should be enclosed in doublequotes to accept = sign (e.g. -config "port=8090" "port.ssl=8043") + final File f = new File (dataRoot,"DATA/SETTINGS/"); + if (!f.exists()) { + mkdirsIfNeseccary(f); + } else { + if (new File(dataRoot, "DATA/yacy.running").exists()) { + System.out.println("please restart YaCy"); } - // use serverSwitch to read config properties (including init values from yacy.init - final serverSwitch ss = new serverSwitch(dataRoot,applicationRoot,"defaults/yacy.init","DATA/SETTINGS/yacy.conf"); - - for (int icnt=1; icnt < args.length ; icnt++) { - final String cfg = args[icnt]; - final int pos = cfg.indexOf('='); - if (pos > 0) { - final String cmd = cfg.substring(0, pos); - final String val = cfg.substring(pos + 1); - - if (!val.isEmpty()) { - if (cmd.equalsIgnoreCase(SwitchboardConstants.ADMIN_ACCOUNT)) { // special command to set adminusername and md5-pwd - final int cpos = val.indexOf(':'); //format adminAccount=adminname:adminpwd - if (cpos >= 0) { - String username = val.substring(0, cpos); - final String pwdtxt = val.substring(cpos + 1); - if (!username.isEmpty()) { - ss.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, username); - System.out.println("Set property " + SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME + " = " + username); - } else { - username = ss.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"); - } - ss.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, sb.encodeDigestAuth(username, pwdtxt)); - System.out.println("Set property " + SwitchboardConstants.ADMIN_ACCOUNT_B64MD5 + " = " + ss.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "")); + } + // use serverSwitch to read config properties (including init values from yacy.init + final serverSwitch ss = new serverSwitch(dataRoot,applicationRoot,"defaults/yacy.init","DATA/SETTINGS/yacy.conf"); + + for (int icnt=1; icnt < args.length ; icnt++) { + final String cfg = args[icnt]; + final int pos = cfg.indexOf('='); + if (pos > 0) { + final String cmd = cfg.substring(0, pos); + final String val = cfg.substring(pos + 1); + + if (!val.isEmpty()) { + if (cmd.equalsIgnoreCase(SwitchboardConstants.ADMIN_ACCOUNT)) { // special command to set adminusername and md5-pwd + final int cpos = val.indexOf(':'); //format adminAccount=adminname:adminpwd + if (cpos >= 0) { + String username = val.substring(0, cpos); + final String pwdtxt = val.substring(cpos + 1); + if (!username.isEmpty()) { + ss.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, username); + System.out.println("Set property " + SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME + " = " + username); + } else { + username = ss.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"); } - } else { - ss.setConfig(cmd, val); - System.out.println("Set property " + cmd + " = " + val); + ss.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, sb.encodeDigestAuth(username, pwdtxt)); + System.out.println("Set property " + SwitchboardConstants.ADMIN_ACCOUNT_B64MD5 + " = " + ss.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "")); } + } else { + ss.setConfig(cmd, val); + System.out.println("Set property " + cmd + " = " + val); } - } else { - System.out.println("skip parameter " + cfg + " (equal sign missing, put parameter in doublequotes)"); } - System.out.println(); + } else { + System.out.println("skip parameter " + cfg + " (equal sign missing, put parameter in doublequotes)"); } + System.out.println(); + } } else { if (args.length == 1) { applicationRoot= new File(args[0]); @@ -832,9 +832,9 @@ public final class yacy { } /** -* This class is a helper class whose instance is started, when the java virtual -* machine shuts down. Signals the plasmaSwitchboard to shut down. -*/ + * This class is a helper class whose instance is started, when the java virtual + * machine shuts down. Signals the plasmaSwitchboard to shut down. + */ class shutdownHookThread extends Thread { private final Switchboard sb; private final Semaphore shutdownSemaphore;