Skip to content

Commit

Permalink
Merge pull request #59 from abrami/paper
Browse files Browse the repository at this point in the history
Paper
  • Loading branch information
abrami authored Nov 23, 2023
2 parents e4ef7cd + 7ac9838 commit ff4ddcf
Show file tree
Hide file tree
Showing 31 changed files with 235 additions and 4,425 deletions.
270 changes: 0 additions & 270 deletions DUUI.iml

This file was deleted.

8 changes: 0 additions & 8 deletions DockerUnifiedUIMAInterface.iml

This file was deleted.

Binary file removed performance.db
Binary file not shown.
Binary file removed rest_test.db
Binary file not shown.
Binary file removed serialization_gercorpa.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -18,6 +16,7 @@
*
* Interface between DUUIComposer and WebsocketClient.
*/
@Deprecated
public class DUUIWebsocketAlt implements IDUUIConnectionHandler{

private static List<DUUIWebsocketAlt> clients = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import java.io.ByteArrayInputStream;
import java.util.List;

/**
* Interface for socket connections
*
* @author Dawit Terefe, Givara Ebo
*/
@Deprecated
public interface IDUUIConnectionHandler {

List<ByteArrayInputStream> send(byte[] jc);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.texttechnologylab.DockerUnifiedUIMAInterface.connection;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

Expand All @@ -15,8 +16,11 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
* Interface for WebSocket connections
*
* @author David Terefe
*/
public class WebsocketClient extends WebSocketClient{

List<byte []> messageStack = new ArrayList<>();
Expand Down Expand Up @@ -117,21 +121,21 @@ public void onMessage(ByteBuffer b) {
public void onMessage(String s) {
// System.out.println("[WebsocketClient]: Message Received: " + s);
System.out.println("[WebsocketClient]: Message Received: ");

}

@Override
public void onOpen(ServerHandshake serverHandshake) {
System.out.println("[WebsocketClient]: Opened websocket connection...");

}

@Override
public void onClose(int i, String s, boolean b) {
System.out.println("[WebsocketClient]: CLOSED: i="+i+", s="+s+", b="+b );

}

@Override
public void onError(Exception e) {
System.err.println("[WebsocketClient]: ERROR:" + e.getMessage());
e.getStackTrace();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,5 @@ public Set<String> listCollections() {
return rSet;
}


public String createIndex(String sCollection, String sField) {

BasicDBObject query = new BasicDBObject();
query.put(sField, "text");
String rString = this.getCollection(sCollection).createIndex(query);

return rString;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,19 @@

import static java.lang.String.format;

/**
* Interface for all drivers
*
* @author Alexander Leonhardt
*/
interface ResponsiveMessageCallback {
public void operation(String message);
}

/**
* Driver for the use of Docker
* @author Alexander Leonhardt
*/
public class DUUIDockerDriver implements IDUUIDriverInterface {
private DUUIDockerInterface _interface;
private HttpClient _client;
Expand Down Expand Up @@ -78,6 +87,13 @@ public DUUIDockerDriver() throws IOException, UIMAException, SAXException {
_luaContext = null;
}

/**
* Constructor with built-in timeout
* @param timeout
* @throws IOException
* @throws UIMAException
* @throws SAXException
*/
public DUUIDockerDriver(int timeout) throws IOException, UIMAException, SAXException {
_interface = new DUUIDockerInterface();
_client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(timeout)).build();
Expand All @@ -87,16 +103,18 @@ public DUUIDockerDriver(int timeout) throws IOException, UIMAException, SAXExcep
_active_components = new HashMap<String, InstantiatedComponent>();
}

public void setLuaContext(DUUILuaContext luaContext) {
_luaContext = luaContext;
}

public DUUIDockerDriver withTimeout(int container_timeout_ms) {
_container_timeout = container_timeout_ms;
return this;
}

// TODO: Fragen, ob ich eine analoge Funktion auch für den KubernetesDriver schreiben sollte.
/**
* Creation of the communication layer based on the Driver
* @param url
* @param jc
* @param timeout_ms
* @param client
* @param printfunc
* @param context
* @param skipVerification
* @return
* @throws Exception
*/
public static IDUUICommunicationLayer responsiveAfterTime(String url, JCas jc, int timeout_ms, HttpClient client, ResponsiveMessageCallback printfunc, DUUILuaContext context, boolean skipVerification) throws Exception {
long start = System.currentTimeMillis();
IDUUICommunicationLayer layer = new DUUIFallbackCommunicationLayer(); // Hier wird layer zum ersten mal erstellt.
Expand Down Expand Up @@ -139,8 +157,6 @@ else if(e instanceof CompletionException){
String body2 = new String(resp.body(), Charset.defaultCharset());
try {
printfunc.operation("Component lua communication layer, loading...");

// System.out.printf("Got script %s\n", body2);
IDUUICommunicationLayer lua_com = new DUUILuaCommunicationLayer(body2,"requester",context);
layer = lua_com;
printfunc.operation("Component lua communication layer, loaded.");
Expand Down Expand Up @@ -211,10 +227,41 @@ else if(e instanceof CompletionException){
}
}

/**
* Set Lua-Context
* @param luaContext
*/
public void setLuaContext(DUUILuaContext luaContext) {
_luaContext = luaContext;
}

/**
* Set Timeout
* @param container_timeout_ms
* @return
*/
public DUUIDockerDriver withTimeout(int container_timeout_ms) {
_container_timeout = container_timeout_ms;
return this;
}

/**
* Check whether the image is available.
* @param comp
* @return
*/
public boolean canAccept(DUUIPipelineComponent comp) {
return comp.getDockerImageName()!=null;
}

/**
* Instantiate the component
* @param component
* @param jc
* @param skipVerification
* @return
* @throws Exception
*/
public String instantiate(DUUIPipelineComponent component, JCas jc, boolean skipVerification) throws Exception {
String uuid = UUID.randomUUID().toString();
while (_active_components.containsKey(uuid.toString())) {
Expand Down Expand Up @@ -293,6 +340,10 @@ public String instantiate(DUUIPipelineComponent component, JCas jc, boolean skip
return uuid;
}

/**
* Show the maximum parallelism
* @param uuid
*/
public void printConcurrencyGraph(String uuid) {
InstantiatedComponent component = _active_components.get(uuid);
if (component == null) {
Expand All @@ -301,6 +352,16 @@ public void printConcurrencyGraph(String uuid) {
System.out.printf("[DockerLocalDriver][%s]: Maximum concurrency %d\n",uuid,component.getInstances().size());
}

/**
* Return the TypeSystem used by the given Component
* @param uuid
* @return
* @throws InterruptedException
* @throws IOException
* @throws SAXException
* @throws CompressorException
* @throws ResourceInitializationException
*/
public TypeSystemDescription get_typesystem(String uuid) throws InterruptedException, IOException, SAXException, CompressorException, ResourceInitializationException {
InstantiatedComponent comp = _active_components.get(uuid);
if (comp == null) {
Expand All @@ -309,6 +370,17 @@ public TypeSystemDescription get_typesystem(String uuid) throws InterruptedExcep
return IDUUIInstantiatedPipelineComponent.getTypesystem(uuid,comp);
}

/**
* Execute a component in the driver
* @param uuid
* @param aCas
* @param perf
* @throws InterruptedException
* @throws IOException
* @throws SAXException
* @throws CompressorException
* @throws CASException
*/
public void run(String uuid, JCas aCas, DUUIPipelineDocumentPerformance perf) throws InterruptedException, IOException, SAXException, CompressorException, CASException {
long mutexStart = System.nanoTime();
InstantiatedComponent comp = _active_components.get(uuid);
Expand All @@ -323,10 +395,18 @@ public void run(String uuid, JCas aCas, DUUIPipelineDocumentPerformance perf) th
}
}

/**
* Shutdown of the Docker-Driver
* @hidden
*/
public void shutdown() {

}

/**
* Terminate a component
* @param uuid
*/
public void destroy(String uuid) {
InstantiatedComponent comp = _active_components.remove(uuid);
if (comp == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
import static io.fabric8.kubernetes.client.impl.KubernetesClientImpl.logger;
import static java.lang.String.format;

/**
* Driver for the running of components in Kubernetes
*
* @author Markos Genios, Filip Fitzermann
*/
public class DUUIKubernetesDriver implements IDUUIDriverInterface {

private final KubernetesClient _kube_client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

import java.io.IOException;

/**
* Interface for all drivers
*
* @author Alexander Leonhardt
*/
public interface IDUUIDriverInterface {
public void setLuaContext(DUUILuaContext luaContext);
public boolean canAccept(DUUIPipelineComponent component) throws InvalidXMLException, IOException, SAXException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import java.util.stream.LongStream;

/**
* Class for asynchronous processing of DUUI processes
*
* Class for asynchronous processing of DUUI readers
* @author Giuseppe Abrami
*/
public class DUUIAsynchronousProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,39 @@

/**
* Interface for a CollectionReader
*
* @author Giuseppe Abrami
*/
public interface DUUICollectionReader {

/**
* Get the Progress
*
* @return
*/
ProgressMeter getProgress();

/**
* Fill and get the next JCas
* @param pCas
*/
public void getNextCas(JCas pCas);

/**
* Are there still cas to be processed?
* @return
*/
public boolean hasNext();

/**
* Get size of Collection
* @return
*/
long getSize();

/**
* How many JCas have already been processed?
* @return
*/
long getDone();

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package org.texttechnologylab.DockerUnifiedUIMAInterface.io;

/**
* Serialization interface
*
* @param <T>
*/
public interface SerializeJSON<T> {

/**
* Serialize
* @return
*/
String serialize();

}
Loading

0 comments on commit ff4ddcf

Please sign in to comment.