Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed Jun 6, 2021
1 parent cfcc89c commit 0e48351
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@
* documents from the type 'workitemlob' will be saved, the SnapshotService
* throws a SnapshotException.
* <p>
* <strong>ArchivePushService</strong><br />
* <strong>SyncService</strong><br />
* Since version 2.0 the SnapshotService can be connected to the
* ImixsArchiveService. If the environment variable 'ARCHIVE_SERVICE_ENDPONT' is
* set, than the snapshot service creates a EventLog entry each time a snapshot
* was generated. The ArchivePushService sanns for the EventLog entires in an
* asynchronious way and push the snaphots directyl into the Archive
* was generated. The Archive SyncService scans for the EventLog entries in an
* asynchronous way and pulls the snaphots directly into the Archive
* (Cassandra).
*
*
Expand Down
21 changes: 11 additions & 10 deletions imixs-archive-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ The *Imixs-Archive Service* runs on Jakarta EE and fits perfectly into a microse
All the data is stored in a platform and technology neutral XML format. This guaranties the cross-technology data exchange independent from a specific software version over a long period of time.


## The SyncService

The SyncService pulls Snapshot data from a remote workflow instance into the Imixs-Archive and stores the data into a Cassandra Cluster. The service runns asynchronous and is based on the [Imixs EventLog](https://www.imixs.org/doc/engine/eventlogservice.html).

The SyncService automatically connects to an Imixs-Workflow instance and reads new snapshot data.
The service is triggered by the SyncScheduler implementing a ManagedScheduledExecutorService.

**Note:** A EventLog entry in the remote workflow instance is only created in case the ARCHIVE_SERVICE_ENDPOINT is defined by the remote system. See also the *SnapshotService* EJB in the [imixs-archive-api](../imixs-archive-api/README.md).

## Rest API
The Rest API which is part the *Imixs-Archive-Service* provides methods to update and access snapshot data:
The Rest API which is part the *Imixs-Archive-Service* provides methods to access snapshot data:

* PUT /archive/snapshot/ - stores a snapshot into the archive
* GET /archive/snapshot/{id} - loads a snapshot from the archive
* GET /archive/snapshot/{id}/file/{file} - loads the file content from a snapshot by its filename
* GET /archive/md5/{md5} - loads the file content by its MD5 checksum (recommended)
* GET /archive/metadata - loads the metadata from the archive


## The SyncService

The SyncService pulls a Snapshot data from a remote workflow instance into the cassandra archive. The service uses an asynchronous mechanism based on the Imixs EventLog.

The service connects to an Imixs-Workflow instance by the Rest Client to read new snapshot data.
The service is triggered by the SyncScheduler implementing a ManagedScheduledExecutorService.

**Note:** A EventLog entry in the remote workflow instance is only created in case the ARCHIVE_SERVICE_ENDPOINT is defined by the remote system. See also the *SnapshotService* EJB in the [imixs-archive-api](../imixs-archive-api/README.md).


## The ResyncService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.imixs.workflow.exceptions.InvalidAccessException;

/**
* The SyncService pulls a Snapshot into the cassandra archive. The service uses
* an asynchronous mechanism based on the Imixs EventLog.
* The SyncService pulls a Snapshot into an Apache Cassandra archive. The
* service uses an asynchronous mechanism based on the Imixs EventLog.
* <p>
* The service connects to an Imixs-Workflow instance by the Rest Client to read
* new snapshot data.
Expand Down Expand Up @@ -77,13 +77,12 @@ public void processEventLog(EventLogClient eventLogClient, DocumentClient docume
String id = null;
String ref = null;


if ( documentClient == null || eventLogClient == null) {
if (documentClient == null || eventLogClient == null) {
// no client object
logger.fine("...no eventLogClient available!");
return;
}

// max 100 entries per iteration
eventLogClient.setPageSize(100);
List<ItemCollection> events = eventLogClient.searchEventLog(ImixsArchiveApp.EVENTLOG_TOPIC_ADD,
Expand Down Expand Up @@ -141,7 +140,7 @@ public void releaseDeadLocks(EventLogClient eventLogClient) throws RestAPIExcept
return;
}
eventLogClient.releaseDeadLocks(deadLockInterval, ImixsArchiveApp.EVENTLOG_TOPIC_ADD,
ImixsArchiveApp.EVENTLOG_TOPIC_REMOVE);
ImixsArchiveApp.EVENTLOG_TOPIC_REMOVE);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,66 +284,7 @@ public Response getSnapshotFileByName(@PathParam("snapshotid") String id, @PathP

}

/**
* The method writes the data of a snapshot into the cassandra cluster
* <p>
* The method returns the snapshot data. In case of an failure the method return
* a HTTP Response 500. In this case a client can inspect the items
* '$error_code' and '$error_message' to evaulate the error.
* <p>
* In case the data was successfully written into the Cassandra cluster the
* method returns a HTTP Response 200.
*
* @param xmlworkitem - snapshot data to be stored into cassandra in XML format
* @return - snapshot data with an error code in case of a failure
*/
// @POST
// @Produces(MediaType.APPLICATION_XML)
// @Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML })
// public Response postSnapshot(XMLDocument xmlDocument) {
//
// Session session = null;
// Cluster cluster = null;
// ItemCollection snapshot = XMLDocumentAdapter.putDocument(xmlDocument);
//
// try {
// logger.finest("...write snapshot...");
// dataService.saveSnapshot(snapshot);
// snapshot.removeItem("$error_code");
// snapshot.removeItem("$error_message");
//
// } catch (ArchiveException e) {
// logger.warning("...Failed to initalize imixsarchive keyspace: " + e.getMessage());
// snapshot = this.addErrorMessage(e, snapshot);
//
// return null;
//
// } finally {
// // close session and cluster object
// if (session != null) {
// session.close();
// }
// if (cluster != null) {
// cluster.close();
// }
// }
//
// // return workitem
// try {
// if (snapshot.hasItem("$error_code")) {
// return Response.ok(XMLDataCollectionAdapter.getDataCollection(snapshot), MediaType.APPLICATION_XML)
// .status(Response.Status.NOT_ACCEPTABLE).build();
// }
// else {
// // we do not return a data item
// return Response.ok().build();
// }
// } catch (Exception e) {
// e.printStackTrace();
// return Response.status(Response.Status.NOT_ACCEPTABLE).build();
// }
//
// }


/**
* This method converts a single ItemCollection into a Jax-rs response object.
Expand Down Expand Up @@ -383,28 +324,4 @@ private Response convertResult(ItemCollection workitem, String format) {
}
}

/**
* This helper method adds a error message to the given entity, based on the
* data in a Exception. This kind of error message can be displayed in a page
* evaluating the properties '$error_code' and '$error_message'. These
* attributes will not be stored.
*
* @param pe
*/
// private ItemCollection addErrorMessage(Exception pe, ItemCollection aworkitem) {
//
// if (pe instanceof RuntimeException && pe.getCause() != null) {
// pe = (RuntimeException) pe.getCause();
// }
//
// if (pe instanceof InvalidAccessException) {
// aworkitem.replaceItemValue("$error_code", ((InvalidAccessException) pe).getErrorCode());
// aworkitem.replaceItemValue("$error_message", pe.getMessage());
// } else {
// aworkitem.replaceItemValue("$error_code", "INTERNAL ERROR");
// aworkitem.replaceItemValue("$error_message", pe.getMessage());
// }
//
// return aworkitem;
// }
}

0 comments on commit 0e48351

Please sign in to comment.