Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
change clusterService to @singleton EJB, changed DataService

Issue #61
  • Loading branch information
rsoika committed Jun 12, 2019
1 parent 9780c3a commit 64f9277
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 77 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.Singleton;
//import javax.ejb.Singleton;
import javax.ejb.Stateless;
import javax.inject.Inject;
//import javax.inject.Singleton;

import org.eclipse.microprofile.config.inject.ConfigProperty;

import org.imixs.archive.service.ArchiveException;

import com.datastax.driver.core.Cluster;
Expand All @@ -33,7 +29,6 @@
* @author rsoika
*
*/
@Stateless
@Singleton
public class ClusterService {

Expand All @@ -58,17 +53,12 @@ public class ClusterService {
public static final String TABLE_SCHEMA_SNAPSHOTS = "CREATE TABLE IF NOT EXISTS snapshots (snapshot text, data blob, PRIMARY KEY (snapshot))";
public static final String TABLE_SCHEMA_SNAPSHOTS_BY_UNIQUEID = "CREATE TABLE IF NOT EXISTS snapshots_by_uniqueid (uniqueid text,snapshot text, PRIMARY KEY(uniqueid, snapshot));";
public static final String TABLE_SCHEMA_SNAPSHOTS_BY_MODIFIED = "CREATE TABLE IF NOT EXISTS snapshots_by_modified (modified date,snapshot text,PRIMARY KEY(modified, snapshot));";

// public static final String TABLE_SCHEMA_DOCUMENTS = "CREATE TABLE IF NOT
// EXISTS documents (md5 text, data blob, PRIMARY KEY (md5))";
public static final String TABLE_SCHEMA_DOCUMENTS = "CREATE TABLE IF NOT EXISTS documents (md5 text, sort_id int, data_id text, PRIMARY KEY (md5,sort_id))";
public static final String TABLE_SCHEMA_SNAPSHOTS_BY_DOCUMENT = "CREATE TABLE IF NOT EXISTS snapshots_by_document (md5 text,snapshot text, PRIMARY KEY(md5, snapshot));";
public static final String TABLE_SCHEMA_DOCUMENTS_DATA = "CREATE TABLE IF NOT EXISTS documents_data (data_id text, data blob, PRIMARY KEY (data_id))";

private static Logger logger = Logger.getLogger(ClusterService.class.getName());



@Inject
@ConfigProperty(name =ENV_ARCHIVE_CLUSTER_REPLICATION_FACTOR, defaultValue = "1")
String repFactor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.List;
import java.util.logging.Logger;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.enterprise.event.Event;
import javax.inject.Inject;
Expand All @@ -35,7 +34,6 @@
//import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.SimpleStatement;

/**
Expand Down Expand Up @@ -82,10 +80,10 @@ public class DataService {
public static final String STATEMENT_SELECT_SNAPSHOTS_BY_UNIQUEID = "select * from snapshots_by_uniqueid where uniqueid='?'";
public static final String STATEMENT_SELECT_SNAPSHOTS_BY_MODIFIED = "select * from snapshots_by_modified where modified='?'";

@EJB
@Inject
ClusterService clusterService;

@EJB
@Inject
SyncService schedulerService;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.management.ObjectName;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import java.net.URLDecoder;
import java.util.logging.Logger;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.Encoded;
Expand Down Expand Up @@ -72,10 +72,10 @@
@Stateless
public class ArchiveRestService {

@EJB
@Inject
ClusterService clusterService;

@EJB
@Inject
DataService dataService;

@javax.ws.rs.core.Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

import java.util.logging.Logger;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
Expand All @@ -57,10 +57,10 @@
@Stateless
public class MetatdataRestService {

@EJB
@Inject
ClusterService clusterService;

@EJB
@Inject
DataService dataService;

@javax.ws.rs.core.Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
import java.util.regex.Pattern;

import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.inject.Inject;

import org.imixs.archive.service.ArchiveException;
import org.imixs.archive.service.MessageService;
Expand Down Expand Up @@ -92,16 +92,16 @@ public class RestoreService {

private static Logger logger = Logger.getLogger(RestoreService.class.getName());

@EJB
@Inject
DataService dataService;

@EJB
@Inject
ClusterService clusterService;

@EJB
@Inject
MessageService messageService;

@EJB
@Inject
RemoteAPIService remoteAPIService;

@Resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.logging.Logger;

import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.ejb.ScheduleExpression;
import javax.ejb.Stateless;
import javax.ejb.Timeout;
Expand Down Expand Up @@ -88,16 +87,16 @@ public class SyncService {
@Resource
javax.ejb.TimerService timerService;

@EJB
@Inject
DataService dataService;

@EJB
@Inject
ClusterService clusterService;

@EJB
@Inject
MessageService messageService;

@EJB
@Inject
RemoteAPIService remoteAPIService;

private static Logger logger = Logger.getLogger(SyncService.class.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
Expand All @@ -19,13 +18,9 @@
import org.imixs.archive.service.MessageService;
import org.imixs.archive.service.cassandra.ClusterService;
import org.imixs.archive.service.cassandra.DataService;
import org.imixs.archive.service.scheduler.RestoreService;
import org.imixs.archive.service.scheduler.SyncService;
import org.imixs.workflow.ItemCollection;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;

/**
* CID Bean provide cluster configuration.
*
Expand All @@ -44,16 +39,16 @@ public class ClusterDataController implements Serializable {
String syncSizeUnit = null;
ItemCollection metaData = null;

@EJB
@Inject
ClusterService clusterService;

@EJB
@Inject
DataService dataService;

@EJB
@Inject
SyncService syncService;

@EJB
@Inject
MessageService messageService;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import java.util.List;
import java.util.logging.Logger;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;

import org.imixs.archive.service.ArchiveException;
Expand All @@ -20,8 +19,6 @@
import org.imixs.archive.service.scheduler.SyncService;
import org.imixs.workflow.ItemCollection;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;

/**
* CID Bean to inspect a single process instance.
Expand All @@ -45,33 +42,26 @@ public class InspectController implements Serializable {
List<String> snapshotIDs = null;
String currentSnapshotID=null;

@EJB
@Inject
ClusterService clusterService;

@EJB
@Inject
DataService dataService;

@EJB
@Inject
SyncService syncService;

@EJB
@Inject
MessageService messageService;

@EJB
@Inject
RemoteAPIService remoteAPIService;

public InspectController() {
super();
}

/**
* This method initializes the default sync date
*
*/
@PostConstruct
void init() {

}


public String getUniqueid() {
return uniqueid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.EJB;
import javax.ejb.Timer;
import javax.enterprise.context.RequestScoped;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;

import org.imixs.archive.service.ArchiveException;
Expand All @@ -25,9 +23,6 @@
import org.imixs.archive.service.scheduler.SyncService;
import org.imixs.workflow.ItemCollection;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;

/**
* CID Bean for the resync service.
* <p>
Expand Down Expand Up @@ -57,16 +52,16 @@ public class RestoreController implements Serializable {

protected List<ItemCollection> options = null;

@EJB
@Inject
ClusterService clusterService;

@EJB
@Inject
DataService dataService;

@EJB
@Inject
RestoreService restoreService;

@EJB
@Inject
MessageService messageService;

public RestoreController() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import java.util.logging.Logger;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;

import org.imixs.archive.service.ArchiveException;
Expand All @@ -19,9 +18,6 @@
import org.imixs.archive.service.scheduler.SyncService;
import org.imixs.workflow.ItemCollection;

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;

/**
* CID Bean for the resync service.
* <p>
Expand All @@ -47,13 +43,13 @@ public class ResyncController implements Serializable {
ItemCollection metaData = null;
String newSyncPoint = null;

@EJB
@Inject
ClusterService clusterService;

@EJB
@Inject
DataService dataService;

@EJB
@Inject
MessageService messageService;

public ResyncController() {
Expand Down

0 comments on commit 64f9277

Please sign in to comment.