mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-22 12:48:58 +00:00
(chore) Remove use of deprecated STR.-style string templates
This commit is contained in:
parent
8b8bf0748f
commit
a5b4951f23
@ -40,7 +40,7 @@ public class EdgeUrl implements Serializable {
|
||||
return new URI(urlencodeFixer(url));
|
||||
}
|
||||
catch (URISyntaxException ex) {
|
||||
throw new URISyntaxException(STR."Failed to parse URI '\{url}'", ex.getMessage());
|
||||
throw new URISyntaxException("Failed to parse URI '" + url + "'", ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,6 @@ public record WorkLogEntry(String id, String ts, String path, int cnt) {
|
||||
|
||||
String relPath = fileName();
|
||||
|
||||
return STR."\{relPath.substring(0, 2)}/\{relPath.substring(2, 4)}/\{relPath}";
|
||||
return relPath.substring(0, 2) + "/" + relPath.substring(2, 4) + "/" + relPath;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,9 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
@ -112,7 +114,7 @@ public class GrpcSingleNodeChannelPool<STUB> extends ServiceChangeMonitor {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error(STR."Failed to get channel for \{address}", e);
|
||||
logger.error("Failed to get channel for " + address, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,6 @@ import nu.marginalia.service.discovery.property.ServiceKey;
|
||||
|
||||
public class ServiceNotAvailableException extends RuntimeException {
|
||||
public ServiceNotAvailableException(ServiceKey<?> key) {
|
||||
super(STR."Service \{key} not available");
|
||||
super("Service " + key + " not available");
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,8 @@ package nu.marginalia.service.discovery;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import lombok.SneakyThrows;
|
||||
import nu.marginalia.service.discovery.monitor.*;
|
||||
import nu.marginalia.service.discovery.monitor.ServiceMonitorIf;
|
||||
import nu.marginalia.service.discovery.property.ServiceEndpoint;
|
||||
import static nu.marginalia.service.discovery.property.ServiceEndpoint.*;
|
||||
|
||||
import nu.marginalia.service.discovery.property.ServiceKey;
|
||||
import org.apache.curator.framework.CuratorFramework;
|
||||
import org.apache.curator.utils.ZKPaths;
|
||||
@ -16,9 +14,14 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static nu.marginalia.service.discovery.property.ServiceEndpoint.InstanceAddress;
|
||||
|
||||
/** A versatile service registry that uses ZooKeeper to store service endpoints.
|
||||
* It is used to register services and to look up the endpoints of other services.
|
||||
* <p></p>
|
||||
@ -59,8 +62,8 @@ public class ZkServiceRegistry implements ServiceRegistryIf {
|
||||
{
|
||||
var endpoint = new ServiceEndpoint(externalAddress, requestPort(externalAddress, key));
|
||||
|
||||
String path = STR."\{key.toPath()}/\{instanceUUID.toString()}";
|
||||
byte[] payload = STR."\{endpoint.host()}:\{endpoint.port()}".getBytes(StandardCharsets.UTF_8);
|
||||
String path = key.toPath() + "/" + instanceUUID.toString();
|
||||
byte[] payload = (endpoint.host() + ":" + endpoint.port()).getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
logger.info("Registering {} -> {}", path, endpoint);
|
||||
|
||||
@ -109,7 +112,7 @@ public class ZkServiceRegistry implements ServiceRegistryIf {
|
||||
@Override
|
||||
public void announceInstance(UUID instanceUUID) {
|
||||
try {
|
||||
String serviceRoot = STR."/running-instances/\{instanceUUID.toString()}";
|
||||
String serviceRoot = "/running-instances/" + instanceUUID.toString();
|
||||
|
||||
livenessPaths.add(serviceRoot);
|
||||
|
||||
@ -128,7 +131,7 @@ public class ZkServiceRegistry implements ServiceRegistryIf {
|
||||
*/
|
||||
public boolean isInstanceRunning(UUID instanceUUID) {
|
||||
try {
|
||||
String serviceRoot = STR."/running-instances/\{instanceUUID.toString()}";
|
||||
String serviceRoot = "/running-instances/" + instanceUUID.toString();
|
||||
return null != curatorFramework.checkExists().forPath(serviceRoot);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@ -165,11 +168,11 @@ public class ZkServiceRegistry implements ServiceRegistryIf {
|
||||
curatorFramework.create()
|
||||
.creatingParentsIfNeeded()
|
||||
.withMode(CreateMode.EPHEMERAL)
|
||||
.forPath(STR."/port-registry/\{externalHost}/\{port}", payload);
|
||||
.forPath("/port-registry/" + externalHost + "/" + port, payload);
|
||||
return port;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
logger.error(STR."Still negotiating port for \{identifier}");
|
||||
logger.error("Still negotiating port for " + identifier);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public sealed interface ServiceKey<P extends ServicePartition> {
|
||||
|
||||
record Rest(String name) implements ServiceKey<ServicePartition.None> {
|
||||
public String toPath() {
|
||||
return STR."/services/rest/\{name}";
|
||||
return "/services/rest/" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,10 +51,10 @@ public sealed interface ServiceKey<P extends ServicePartition> {
|
||||
}
|
||||
record Grpc<P extends ServicePartition>(String name, P partition) implements ServiceKey<P> {
|
||||
public String baseName() {
|
||||
return STR."/services/grpc/\{name}";
|
||||
return "/services/grpc/" + name;
|
||||
}
|
||||
public String toPath() {
|
||||
return STR."/services/grpc/\{name}/\{partition.identifier()}";
|
||||
return "/services/grpc/" + name + "/" + partition.identifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,7 +24,7 @@ public class NamedExecutorFactory {
|
||||
|
||||
@Override
|
||||
public Thread newThread(@NotNull Runnable r) {
|
||||
var thread = new Thread(r, STR."\{name}[\{threadNumber.getAndIncrement()}]");
|
||||
var thread = new Thread(r, name + "[" + threadNumber.getAndIncrement() + "]");
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package nu.marginalia.service.discovery;
|
||||
|
||||
import nu.marginalia.service.ServiceId;
|
||||
import nu.marginalia.service.discovery.monitor.ServiceMonitorIf;
|
||||
import nu.marginalia.service.discovery.property.ServiceKey;
|
||||
import nu.marginalia.service.discovery.property.ServicePartition;
|
||||
import nu.marginalia.service.ServiceId;
|
||||
import nu.marginalia.test.TestApiGrpc;
|
||||
import org.apache.curator.framework.CuratorFrameworkFactory;
|
||||
import org.apache.curator.retry.ExponentialBackoffRetry;
|
||||
@ -33,7 +33,7 @@ class ZkServiceRegistryTest {
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
zookeeper.start();
|
||||
connectString = STR."\{zookeeper.getHost()}:\{zookeeper.getMappedPort(ZOOKEEPER_PORT)}";
|
||||
connectString = zookeeper.getHost() + ":" + zookeeper.getMappedPort(ZOOKEEPER_PORT);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
|
@ -6,6 +6,8 @@ import nu.marginalia.process.log.WorkLogEntry;
|
||||
import nu.marginalia.storage.FileStorageService;
|
||||
import nu.marginalia.storage.model.FileStorage;
|
||||
import nu.marginalia.storage.model.FileStorageId;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@ -18,9 +20,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
|
||||
public class SampleDataExporter {
|
||||
private final FileStorageService storageService;
|
||||
|
||||
@ -57,16 +56,13 @@ public class SampleDataExporter {
|
||||
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--")));
|
||||
try (var bw = Files.newBufferedWriter(newCrawlerLogFile, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
|
||||
for (var item : entriesAll) {
|
||||
bw.write(STR."\{item.id()} \{item.ts()} \{item.relPath()} \{item.cnt()}\n");
|
||||
bw.write(item.id() + " " + item.ts() + " " + item.relPath() + " " + item.cnt() + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
Path newManifestJsonFile = Files.createTempFile(destStorage.asPath(), "manifest", ".json",
|
||||
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--")));
|
||||
Files.writeString(newManifestJsonFile, STR."""
|
||||
{ "description": "\{name.replace("[\"\\]", "_")}",
|
||||
"type": "CRAWL_DATA" }
|
||||
""");
|
||||
Files.writeString(newManifestJsonFile, " { \"description\": \"" + name.replace("[\"\\]", "_") + "\",\n \"type\": \"CRAWL_DATA\" }\n");
|
||||
|
||||
var tmpTarFile = Files.createTempFile(destStorage.asPath(), "data", ".tar",
|
||||
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--")));
|
||||
|
@ -8,6 +8,9 @@ import nu.marginalia.actor.state.ActorResumeBehavior;
|
||||
import nu.marginalia.actor.state.ActorStep;
|
||||
import nu.marginalia.actor.state.Resume;
|
||||
import nu.marginalia.encyclopedia.EncyclopediaConverter;
|
||||
import nu.marginalia.mq.MqMessageState;
|
||||
import nu.marginalia.mq.outbox.MqOutbox;
|
||||
import nu.marginalia.mqapi.converting.ConvertRequest;
|
||||
import nu.marginalia.process.ProcessOutboxes;
|
||||
import nu.marginalia.process.ProcessService;
|
||||
import nu.marginalia.sideload.RedditSideloadHelper;
|
||||
@ -17,9 +20,6 @@ import nu.marginalia.storage.FileStorageService;
|
||||
import nu.marginalia.storage.model.FileStorageId;
|
||||
import nu.marginalia.storage.model.FileStorageState;
|
||||
import nu.marginalia.storage.model.FileStorageType;
|
||||
import nu.marginalia.mq.MqMessageState;
|
||||
import nu.marginalia.mq.outbox.MqOutbox;
|
||||
import nu.marginalia.mqapi.converting.ConvertRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -140,7 +140,7 @@ public class ConvertActor extends RecordActorPrototype {
|
||||
// To avoid re-converting the same file, we'll assign the file a name based on its hash
|
||||
// and the original filename. This way, if we're fed the same file again, we'll be able to just
|
||||
// re-use the predigested database file.
|
||||
yield new PredigestEncyclopedia(source, STR."\{source}.\{hash}.db", baseUrl);
|
||||
yield new PredigestEncyclopedia(source, source + "." + hash + ".db", baseUrl);
|
||||
} else if (!source.endsWith(".db")) {
|
||||
yield new Error("Source path must be a ZIM or pre-digested sqlite database file (.db)");
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class ExportSampleDataActor extends RecordActorPrototype {
|
||||
case Export(FileStorageId crawlId, int size, String name) -> {
|
||||
var storage = storageService.allocateStorage(FileStorageType.EXPORT,
|
||||
"crawl-sample-export",
|
||||
STR."Crawl Data Sample \{name}/\{size} \{LocalDateTime.now()}"
|
||||
"Crawl Data Sample " + name + "/" + size + " " + LocalDateTime.now()
|
||||
);
|
||||
|
||||
if (storage == null) yield new Error("Bad storage id");
|
||||
|
@ -9,7 +9,8 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.*;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.stream.Collectors;
|
||||
@ -97,7 +98,7 @@ public class RedditSideloadHelper {
|
||||
|
||||
private static Path getRedditDbPath(RedditFilePair pair) throws IOException {
|
||||
String hash = SideloadHelper.getCrc32FileHash(pair.commentsPath());
|
||||
return pair.rootDir().resolve(STR."\{pair.fileNameBase}.\{hash}.db");
|
||||
return pair.rootDir().resolve(pair.fileNameBase + "." + hash + ".db");
|
||||
}
|
||||
|
||||
}
|
@ -83,7 +83,7 @@ public class StackExchangeSideloadHelper {
|
||||
String fileName = sourcePath.toFile().getName();
|
||||
String hash = SideloadHelper.getCrc32FileHash(sourcePath);
|
||||
|
||||
return sourcePath.getParent().resolve(STR."\{fileName}.\{hash}.db");
|
||||
return sourcePath.getParent().resolve(fileName + "." + hash + ".db");
|
||||
}
|
||||
|
||||
private static Optional<String> getStackexchangeDomainFromFilename(String fileName) {
|
||||
|
@ -56,10 +56,7 @@ public class DomainInformationService {
|
||||
|
||||
ResultSet rs;
|
||||
|
||||
rs = stmt.executeQuery(STR."""
|
||||
SELECT IP, NODE_AFFINITY, DOMAIN_NAME, STATE, IFNULL(RANK, 1) AS RANK
|
||||
FROM EC_DOMAIN WHERE ID=\{domainId}
|
||||
""");
|
||||
rs = stmt.executeQuery("SELECT IP, NODE_AFFINITY, DOMAIN_NAME, STATE, IFNULL(RANK, 1) AS RANK\n FROM EC_DOMAIN WHERE ID=" + domainId + "\n ");
|
||||
if (rs.next()) {
|
||||
String ip = rs.getString("IP");
|
||||
|
||||
@ -77,20 +74,14 @@ public class DomainInformationService {
|
||||
builder.setState(rs.getString("STATE"));
|
||||
builder.setRanking(Math.round(100.0*(1.0-rs.getDouble("RANK"))));
|
||||
}
|
||||
rs = stmt.executeQuery(STR."""
|
||||
SELECT 1 FROM CRAWL_QUEUE
|
||||
INNER JOIN EC_DOMAIN ON CRAWL_QUEUE.DOMAIN_NAME = EC_DOMAIN.DOMAIN_NAME
|
||||
WHERE EC_DOMAIN.ID=\{domainId}
|
||||
""");
|
||||
rs = stmt.executeQuery("SELECT 1 FROM CRAWL_QUEUE\nINNER JOIN EC_DOMAIN ON CRAWL_QUEUE.DOMAIN_NAME = EC_DOMAIN.DOMAIN_NAME\nWHERE EC_DOMAIN.ID=" + domainId + "\n ");
|
||||
inCrawlQueue = rs.next();
|
||||
builder.setInCrawlQueue(inCrawlQueue);
|
||||
|
||||
builder.setIncomingLinks(linkGraphClient.countLinksToDomain(domainId));
|
||||
builder.setOutboundLinks(linkGraphClient.countLinksFromDomain(domainId));
|
||||
|
||||
rs = stmt.executeQuery(STR."""
|
||||
SELECT KNOWN_URLS, GOOD_URLS, VISITED_URLS FROM DOMAIN_METADATA WHERE ID=\{domainId}
|
||||
""");
|
||||
rs = stmt.executeQuery("SELECT KNOWN_URLS, GOOD_URLS, VISITED_URLS FROM DOMAIN_METADATA WHERE ID=" + domainId + "\n ");
|
||||
if (rs.next()) {
|
||||
pagesVisited = rs.getInt("VISITED_URLS");
|
||||
|
||||
|
@ -48,7 +48,7 @@ public record QWord(
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return STR."q{\{word}}";
|
||||
return "q{" + word + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -238,7 +238,7 @@ public class QWordGraph implements Iterable<QWord> {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("digraph {\n");
|
||||
for (var link : links) {
|
||||
sb.append(STR."\"\{link.from().word()}\" -> \"\{link.to.word()}\";\n");
|
||||
sb.append("\"" + link.from().word() + "\" -> \"" + link.to.word() + "\";\n");
|
||||
}
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
|
@ -63,6 +63,6 @@ public class QWordPath {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return STR."WordPath{nodes=\{nodes}\{'}'}";
|
||||
return "WordPath{nodes=" + nodes + '}';
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class QWordPathsRenderer {
|
||||
// Recurse into the branches:
|
||||
String branchPart = render(e.getValue(), reachability);
|
||||
|
||||
return STR."\{commonWord} \{branchPart}";
|
||||
return commonWord + " " + branchPart;
|
||||
})
|
||||
.collect(Collectors.joining(" | ", " ( ", " ) "));
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class SegmentLongArray implements LongArray {
|
||||
final int stride = 1024*1024*128; // Copy 1 GB at a time 'cause byte buffers are 'a byte buffering
|
||||
|
||||
if (source.size() / 8 < sourceStart + (arrayEnd - arrayStart)) {
|
||||
throw new IndexOutOfBoundsException(STR."Source channel too small: \{source.size()} < \{sourceStart + (arrayEnd - arrayStart)}");
|
||||
throw new IndexOutOfBoundsException("Source channel too small: " + source.size() + " < " + (sourceStart + (arrayEnd - arrayStart)));
|
||||
}
|
||||
|
||||
long ss = sourceStart;
|
||||
|
@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class BitWriterTest {
|
||||
|
||||
@ -52,7 +52,7 @@ class BitWriterTest {
|
||||
byte actual = out.get(0);
|
||||
byte expected = (byte) 0b1011_1110;
|
||||
|
||||
assertEquals(expected, actual, STR."was \{Integer.toBinaryString(actual & 0xFF)}");
|
||||
assertEquals(expected, actual, "was " + Integer.toBinaryString(actual & 0xFF));
|
||||
assertEquals(1, out.limit());
|
||||
}
|
||||
|
||||
@ -84,8 +84,8 @@ class BitWriterTest {
|
||||
byte expected1 = (byte) 0b1011_1110;
|
||||
byte expected2 = (byte) 0b1100_0000;
|
||||
|
||||
assertEquals(expected1, actual1, STR."was \{Integer.toBinaryString(actual1 & 0xFF)}");
|
||||
assertEquals(expected2, actual2, STR."was \{Integer.toBinaryString(actual2 & 0xFF)}");
|
||||
assertEquals(expected1, actual1, "was " + Integer.toBinaryString(actual1 & 0xFF));
|
||||
assertEquals(expected2, actual2, "was " + Integer.toBinaryString(actual2 & 0xFF));
|
||||
|
||||
}
|
||||
|
||||
@ -118,13 +118,13 @@ class BitWriterTest {
|
||||
byte actual1 = out.get(i);
|
||||
byte expected1 = (byte) 0b1011_1110;
|
||||
|
||||
assertEquals(expected1, actual1, STR."was \{Integer.toBinaryString(actual1 & 0xFF)}");
|
||||
assertEquals(expected1, actual1, "was " + Integer.toBinaryString(actual1 & 0xFF));
|
||||
}
|
||||
|
||||
byte actual2 = out.get(4);
|
||||
byte expected2 = (byte) 0b1100_0000;
|
||||
|
||||
assertEquals(expected2, actual2, STR."was \{Integer.toBinaryString(actual2 & 0xFF)}");
|
||||
assertEquals(expected2, actual2, "was " + Integer.toBinaryString(actual2 & 0xFF));
|
||||
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ public class ConverterMain extends ProcessMainClass {
|
||||
};
|
||||
}
|
||||
catch (Exception ex) {
|
||||
inbox.sendResponse(msg, MqInboxResponse.err(STR."\{ex.getClass().getSimpleName()}: \{ex.getMessage()}"));
|
||||
inbox.sendResponse(msg, MqInboxResponse.err(ex.getClass().getSimpleName() + ": " + ex.getMessage()));
|
||||
|
||||
throw ex;
|
||||
}
|
||||
|
@ -116,21 +116,7 @@ public class RedditSideloader implements SideloadSource {
|
||||
.ofInstant(Instant.ofEpochSecond(createdUtc), ZoneOffset.UTC)
|
||||
.getYear();
|
||||
|
||||
String fullHtml = STR."""
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>\{title}</title>
|
||||
<script src="https://www.example.com/dummy.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>\{title}</h1>
|
||||
<article>
|
||||
<p>\{body}</p>
|
||||
</article>
|
||||
</body>
|
||||
</html>
|
||||
""";
|
||||
String fullHtml = "<!DOCTYPE html>\n<html>\n<head>\n <title>" + title + "</title>\n <script src=\"https://www.example.com/dummy.js\" type=\"text/javascript\"></script>\n</head>\n<body>\n <h1>" + title + "</h1>\n <article>\n <p>" + body + "</p>\n </article>\n</body>\n</html>\n";
|
||||
|
||||
List<String> extraKeywords = new ArrayList<>();
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class RedditDb {
|
||||
{
|
||||
Files.deleteIfExists(dbFile);
|
||||
|
||||
try (var connection = DriverManager.getConnection(STR."jdbc:sqlite:\{dbFile}");
|
||||
try (var connection = DriverManager.getConnection("jdbc:sqlite:" + dbFile);
|
||||
var stream = ClassLoader.getSystemResourceAsStream("db/reddit.sql");
|
||||
var updateStmt = connection.createStatement()
|
||||
) {
|
||||
@ -91,12 +91,12 @@ public class RedditDb {
|
||||
}
|
||||
|
||||
public static SubmissionIterator getSubmissions(Path file) throws SQLException {
|
||||
var connection = DriverManager.getConnection(STR."jdbc:sqlite:\{file}");
|
||||
var connection = DriverManager.getConnection("jdbc:sqlite:" + file);
|
||||
|
||||
return new SubmissionIterator(connection);
|
||||
}
|
||||
public static CommentIterator getComments(Path file) throws SQLException {
|
||||
var connection = DriverManager.getConnection(STR."jdbc:sqlite:\{file}");
|
||||
var connection = DriverManager.getConnection("jdbc:sqlite:" + file);
|
||||
|
||||
return new CommentIterator(connection);
|
||||
}
|
||||
|
@ -26,6 +26,6 @@ public record ContentType(String contentType, String charset) {
|
||||
if (charset == null || charset.isBlank())
|
||||
return contentType;
|
||||
|
||||
return STR."\{contentType}; charset=\{charset}";
|
||||
return contentType + "; charset=" + charset;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class CrawlerOutputFile {
|
||||
if (!Files.exists(destDir)) {
|
||||
Files.createDirectories(destDir);
|
||||
}
|
||||
return destDir.resolve(STR."\{id}-\{filesystemSafeName(domain)}-\{version.suffix}.warc.gz");
|
||||
return destDir.resolve(id + "-" + filesystemSafeName(domain) + "-" + version.suffix + ".warc.gz");
|
||||
}
|
||||
|
||||
public static Path createParquetPath(Path basePath, String id, String domain) throws IOException {
|
||||
@ -45,7 +45,7 @@ public class CrawlerOutputFile {
|
||||
if (!Files.exists(destDir)) {
|
||||
Files.createDirectories(destDir);
|
||||
}
|
||||
return destDir.resolve(STR."\{id}-\{filesystemSafeName(domain)}.parquet");
|
||||
return destDir.resolve(id + "-" + filesystemSafeName(domain) + ".parquet");
|
||||
}
|
||||
public static Path getParquetPath(Path basePath, String id, String domain) {
|
||||
id = padId(id);
|
||||
@ -54,7 +54,7 @@ public class CrawlerOutputFile {
|
||||
String second = id.substring(2, 4);
|
||||
|
||||
Path destDir = basePath.resolve(first).resolve(second);
|
||||
return destDir.resolve(STR."\{id}-\{filesystemSafeName(domain)}.parquet");
|
||||
return destDir.resolve(id + "-" + filesystemSafeName(domain) + ".parquet");
|
||||
}
|
||||
public static Path getWarcPath(Path basePath, String id, String domain, WarcFileVersion version) {
|
||||
id = padId(id);
|
||||
@ -63,7 +63,7 @@ public class CrawlerOutputFile {
|
||||
String second = id.substring(2, 4);
|
||||
|
||||
Path destDir = basePath.resolve(first).resolve(second);
|
||||
return destDir.resolve(STR."\{id}-\{filesystemSafeName(domain)}.warc\{version.suffix}");
|
||||
return destDir.resolve(id + "-" + filesystemSafeName(domain) + ".warc" + version.suffix);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,7 +181,7 @@ public class CrawledDocumentParquetRecordFileWriter implements AutoCloseable {
|
||||
|
||||
private CrawledDocumentParquetRecord forDomainRedirect(String domain, Instant date, String redirectDomain) {
|
||||
return new CrawledDocumentParquetRecord(domain,
|
||||
STR."https://\{redirectDomain}/",
|
||||
"https://" + redirectDomain + "/",
|
||||
"",
|
||||
false,
|
||||
0,
|
||||
@ -195,7 +195,7 @@ public class CrawledDocumentParquetRecordFileWriter implements AutoCloseable {
|
||||
}
|
||||
private CrawledDocumentParquetRecord forDomainError(String domain, Instant date, String ip, String errorStatus) {
|
||||
return new CrawledDocumentParquetRecord(domain,
|
||||
STR."https://\{domain}/",
|
||||
"https://" + domain + "/",
|
||||
ip,
|
||||
false,
|
||||
0,
|
||||
|
@ -55,7 +55,7 @@ public class BangCommand implements SearchCommandInterface {
|
||||
String prefix = bm.prefix().trim();
|
||||
String suffix = bm.suffix(bangKey.length()).trim();
|
||||
|
||||
String ret = STR."\{prefix} \{suffix}".trim();
|
||||
String ret = (prefix + " " + suffix).trim();
|
||||
|
||||
return Optional.of(ret)
|
||||
.filter(s -> !s.isBlank());
|
||||
|
@ -20,7 +20,7 @@ public record ProcessHeartbeat(
|
||||
}
|
||||
public String progressStyle() {
|
||||
if ("RUNNING".equals(status) && progress != null) {
|
||||
return STR."background: linear-gradient(90deg, #ccc 0%, #ccc \{progress}%, #fff \{progress}%)";
|
||||
return "background: linear-gradient(90deg, #ccc 0%, #ccc " + progress + "%, #fff " + progress + "%)";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public record TaskHeartbeat(
|
||||
|
||||
public String progressStyle() {
|
||||
if ("RUNNING".equals(status) && progress != null) {
|
||||
return STR."background: linear-gradient(90deg, #ccc 0%, #ccc \{progress}%, #fff \{progress}%)";
|
||||
return "background: linear-gradient(90deg, #ccc 0%, #ccc " + progress + "%, #fff " + progress + "%)";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -83,15 +83,11 @@ public class AbortedProcessService {
|
||||
|
||||
// Generate all possible values for process-related inboxes
|
||||
String inboxes = Stream.of("converter", "loader", "crawler")
|
||||
.flatMap(s -> allNodeIds.stream().map(i -> STR."'\{s}:\{i}'"))
|
||||
.flatMap(s -> allNodeIds.stream().map(i -> "'" + s + ":" + i + "'"))
|
||||
.collect(Collectors.joining(",", "(", ")"));
|
||||
|
||||
try (var conn = dataSource.getConnection()) {
|
||||
var stmt = conn.prepareStatement(STR."""
|
||||
SELECT ID, RECIPIENT_INBOX, CREATED_TIME, UPDATED_TIME, PAYLOAD FROM MESSAGE_QUEUE
|
||||
WHERE STATE = 'DEAD'
|
||||
AND RECIPIENT_INBOX IN \{inboxes}
|
||||
"""); // SQL injection safe, string is not user input
|
||||
var stmt = conn.prepareStatement("SELECT ID, RECIPIENT_INBOX, CREATED_TIME, UPDATED_TIME, PAYLOAD FROM MESSAGE_QUEUE\nWHERE STATE = 'DEAD'\nAND RECIPIENT_INBOX IN " + inboxes + "\n"); // SQL injection safe, string is not user input
|
||||
var rs = stmt.executeQuery();
|
||||
|
||||
List<AbortedProcess> abortedProcesses = new ArrayList<>();
|
||||
|
@ -57,12 +57,7 @@ public class SingleService {
|
||||
int httpPort = Integer.parseInt(bindParts[1]);
|
||||
int grpcPort = Integer.parseInt(bindParts[2]);
|
||||
|
||||
System.out.println(STR."""
|
||||
Configuring service with bind address: \{bindAddress}
|
||||
http port: \{httpPort}
|
||||
grpc port: \{grpcPort}
|
||||
announce address: \{announceAddress}
|
||||
""");
|
||||
System.out.println("Configuring service with bind address: " + bindAddress + "\n http port: " + httpPort + "\n grpc port: " + grpcPort + "\n announce address: " + announceAddress + "\n");
|
||||
|
||||
System.setProperty("service.bind-address", bindAddress);
|
||||
System.setProperty("service.http-port", Integer.toString(httpPort));
|
||||
|
Loading…
Reference in New Issue
Block a user