/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/ALFSecurityType.java |
---|
File deleted |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/ALFEventBase_1.xsd |
---|
File deleted |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/ALFEventManagerDocLit.xsd |
---|
File deleted |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/ALFEventResponseType.java |
---|
1,13 → 1,10 |
package net.brutex.xservices.types.alfevent; |
import java.util.ArrayList; |
import java.util.List; |
import javax.xml.bind.annotation.XmlAccessType; |
import javax.xml.bind.annotation.XmlAccessorType; |
import javax.xml.bind.annotation.XmlAnyElement; |
import javax.xml.bind.annotation.XmlType; |
import org.w3c.dom.Element; |
/** |
20,7 → 17,7 |
* <complexContent> |
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
* <sequence> |
* <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/> |
* <any minOccurs="0"/> |
* </sequence> |
* </restriction> |
* </complexContent> |
36,36 → 33,30 |
public class ALFEventResponseType { |
@XmlAnyElement(lax = true) |
protected List<Object> any; |
protected Object any; |
/** |
* Gets the value of the any property. |
* Ruft den Wert der any-Eigenschaft ab. |
* |
* <p> |
* This accessor method returns a reference to the live list, |
* not a snapshot. Therefore any modification you make to the |
* returned list will be present inside the JAXB object. |
* This is why there is not a <CODE>set</CODE> method for the any property. |
* @return |
* possible object is |
* {@link Object } |
* |
* <p> |
* For example, to add a new item, do as follows: |
* <pre> |
* getAny().add(newItem); |
* </pre> |
*/ |
public Object getAny() { |
return any; |
} |
/** |
* Legt den Wert der any-Eigenschaft fest. |
* |
* |
* <p> |
* Objects of the following type(s) are allowed in the list |
* {@link Element } |
* @param value |
* allowed object is |
* {@link Object } |
* |
* |
*/ |
public List<Object> getAny() { |
if (any == null) { |
any = new ArrayList<Object>(); |
public void setAny(Object value) { |
this.any = value; |
} |
return this.any; |
} |
} |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/ALFEventType.java |
---|
145,8 → 145,8 |
* |
* <p> |
* Objects of the following type(s) are allowed in the list |
* {@link Object } |
* {@link Element } |
* {@link Object } |
* |
* |
*/ |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/ALFEventWithReplyResponseType.java |
---|
1,13 → 1,10 |
package net.brutex.xservices.types.alfevent; |
import java.util.ArrayList; |
import java.util.List; |
import javax.xml.bind.annotation.XmlAccessType; |
import javax.xml.bind.annotation.XmlAccessorType; |
import javax.xml.bind.annotation.XmlAnyElement; |
import javax.xml.bind.annotation.XmlType; |
import org.w3c.dom.Element; |
/** |
20,7 → 17,7 |
* <complexContent> |
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
* <sequence> |
* <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/> |
* <any minOccurs="0"/> |
* </sequence> |
* </restriction> |
* </complexContent> |
36,36 → 33,30 |
public class ALFEventWithReplyResponseType { |
@XmlAnyElement(lax = true) |
protected List<Object> any; |
protected Object any; |
/** |
* Gets the value of the any property. |
* Ruft den Wert der any-Eigenschaft ab. |
* |
* <p> |
* This accessor method returns a reference to the live list, |
* not a snapshot. Therefore any modification you make to the |
* returned list will be present inside the JAXB object. |
* This is why there is not a <CODE>set</CODE> method for the any property. |
* @return |
* possible object is |
* {@link Object } |
* |
* <p> |
* For example, to add a new item, do as follows: |
* <pre> |
* getAny().add(newItem); |
* </pre> |
*/ |
public Object getAny() { |
return any; |
} |
/** |
* Legt den Wert der any-Eigenschaft fest. |
* |
* |
* <p> |
* Objects of the following type(s) are allowed in the list |
* {@link Element } |
* @param value |
* allowed object is |
* {@link Object } |
* |
* |
*/ |
public List<Object> getAny() { |
if (any == null) { |
any = new ArrayList<Object>(); |
public void setAny(Object value) { |
this.any = value; |
} |
return this.any; |
} |
} |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/BaseExtensionType.java |
---|
11,7 → 11,6 |
import javax.xml.bind.annotation.XmlAnyElement; |
import javax.xml.bind.annotation.XmlType; |
import javax.xml.namespace.QName; |
import org.w3c.dom.Element; |
/** |
29,7 → 28,7 |
* <complexContent> |
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
* <sequence> |
* <any processContents='lax' namespace='http://www.eclipse.org/alf/schema/EventBase/1' maxOccurs="unbounded"/> |
* <any namespace='targetnamespace' maxOccurs="unbounded"/> |
* </sequence> |
* <anyAttribute/> |
* </restriction> |
68,7 → 67,6 |
* |
* <p> |
* Objects of the following type(s) are allowed in the list |
* {@link Element } |
* {@link Object } |
* |
* |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/CredentialsType.java |
---|
9,7 → 9,6 |
import javax.xml.bind.annotation.XmlAccessorType; |
import javax.xml.bind.annotation.XmlAnyAttribute; |
import javax.xml.bind.annotation.XmlAnyElement; |
import javax.xml.bind.annotation.XmlElement; |
import javax.xml.bind.annotation.XmlType; |
import javax.xml.namespace.QName; |
import org.w3c.dom.Element; |
17,9 → 16,8 |
/** |
* |
* A structure to hold security |
* authentication-relevant data. If present the |
* data within may be encrypted. |
* A structure to hold security authentication-relevant data. |
* If present the data within may be encrypted. |
* |
* |
* <p>Java-Klasse für CredentialsType complex type. |
31,8 → 29,7 |
* <complexContent> |
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
* <sequence> |
* <element name="ALFSecurity" type="{http://www.eclipse.org/alf/schema/EventBase/1}ALFSecurityType" minOccurs="0"/> |
* <any processContents='lax' namespace='##other' maxOccurs="unbounded" minOccurs="0"/> |
* <any processContents='lax' maxOccurs="unbounded" minOccurs="0"/> |
* </sequence> |
* <anyAttribute/> |
* </restriction> |
44,13 → 41,10 |
*/ |
@XmlAccessorType(XmlAccessType.FIELD) |
@XmlType(name = "CredentialsType", namespace = "http://www.eclipse.org/alf/schema/EventBase/1", propOrder = { |
"alfSecurity", |
"any" |
}) |
public class CredentialsType { |
@XmlElement(name = "ALFSecurity", namespace = "http://www.eclipse.org/alf/schema/EventBase/1") |
protected ALFSecurityType alfSecurity; |
@XmlAnyElement(lax = true) |
protected List<Object> any; |
@XmlAnyAttribute |
57,30 → 51,6 |
private Map<QName, String> otherAttributes = new HashMap<QName, String>(); |
/** |
* Ruft den Wert der alfSecurity-Eigenschaft ab. |
* |
* @return |
* possible object is |
* {@link ALFSecurityType } |
* |
*/ |
public ALFSecurityType getALFSecurity() { |
return alfSecurity; |
} |
/** |
* Legt den Wert der alfSecurity-Eigenschaft fest. |
* |
* @param value |
* allowed object is |
* {@link ALFSecurityType } |
* |
*/ |
public void setALFSecurity(ALFSecurityType value) { |
this.alfSecurity = value; |
} |
/** |
* Gets the value of the any property. |
* |
* <p> |
98,8 → 68,8 |
* |
* <p> |
* Objects of the following type(s) are allowed in the list |
* {@link Object } |
* {@link Element } |
* {@link Object } |
* |
* |
*/ |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/CustomExtensionType.java |
---|
17,7 → 17,6 |
/** |
* |
* Place holder type for custom Event payload "extensions" |
* ##other namespace is recommended but ##any is specified allowing more primitive sources |
* |
* |
* <p>Java-Klasse für CustomExtensionType complex type. |
29,7 → 28,7 |
* <complexContent> |
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
* <sequence> |
* <any processContents='lax' maxOccurs="unbounded"/> |
* <any processContents='lax' namespace='##other' maxOccurs="unbounded"/> |
* </sequence> |
* <anyAttribute/> |
* </restriction> |
68,8 → 67,8 |
* |
* <p> |
* Objects of the following type(s) are allowed in the list |
* {@link Object } |
* {@link Element } |
* {@link Object } |
* |
* |
*/ |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/DetailExtensionType.java |
---|
16,8 → 16,7 |
/** |
* |
* Place holder type for vocabulary based Event payload |
* "details" |
* Place holder type for vocabulary based Event payload "details" |
* |
* |
* <p>Java-Klasse für DetailExtensionType complex type. |
68,8 → 67,8 |
* |
* <p> |
* Objects of the following type(s) are allowed in the list |
* {@link Object } |
* {@link Element } |
* {@link Object } |
* |
* |
*/ |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/EmBaseType.java |
---|
31,7 → 31,7 |
* <complexContent> |
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
* <sequence> |
* <element name="EmEventId" type="{http://www.eclipse.org/alf/schema/EventBase/1}EventIdType"/> |
* <element name="EmEventId" type="{http://www.w3.org/2001/XMLSchema}string"/> |
* <element name="EmTimestamp" type="{http://www.eclipse.org/alf/schema/EventBase/1}TimestampType"/> |
* <element name="PrecedingEmEventId" type="{http://www.eclipse.org/alf/schema/EventBase/1}EventIdType"/> |
* <element name="ApplicationName" type="{http://www.eclipse.org/alf/schema/EventBase/1}ApplicationNameType"/> |
41,7 → 41,6 |
* <element name="Callback" type="{http://www.w3.org/2001/XMLSchema}boolean"/> |
* <element name="Environment" type="{http://www.eclipse.org/alf/schema/EventBase/1}EnvironmentType"/> |
* <element name="EmUser" type="{http://www.eclipse.org/alf/schema/EventBase/1}CredentialsType"/> |
* <element name="AttemptCount" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/> |
* <element name="EmExtension" type="{http://www.eclipse.org/alf/schema/EventBase/1}EmExtensionType" minOccurs="0"/> |
* </sequence> |
* <anyAttribute/> |
64,7 → 63,6 |
"callback", |
"environment", |
"emUser", |
"attemptCount", |
"emExtension" |
}) |
public class EmBaseType { |
90,8 → 88,6 |
protected String environment; |
@XmlElement(name = "EmUser", namespace = "http://www.eclipse.org/alf/schema/EventBase/1", required = true) |
protected CredentialsType emUser; |
@XmlElement(name = "AttemptCount", namespace = "http://www.eclipse.org/alf/schema/EventBase/1") |
protected Integer attemptCount; |
@XmlElement(name = "EmExtension", namespace = "http://www.eclipse.org/alf/schema/EventBase/1") |
protected EmExtensionType emExtension; |
@XmlAnyAttribute |
330,30 → 326,6 |
} |
/** |
* Ruft den Wert der attemptCount-Eigenschaft ab. |
* |
* @return |
* possible object is |
* {@link Integer } |
* |
*/ |
public Integer getAttemptCount() { |
return attemptCount; |
} |
/** |
* Legt den Wert der attemptCount-Eigenschaft fest. |
* |
* @param value |
* allowed object is |
* {@link Integer } |
* |
*/ |
public void setAttemptCount(Integer value) { |
this.attemptCount = value; |
} |
/** |
* Ruft den Wert der emExtension-Eigenschaft ab. |
* |
* @return |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/EmExtensionType.java |
---|
11,7 → 11,6 |
import javax.xml.bind.annotation.XmlAnyElement; |
import javax.xml.bind.annotation.XmlType; |
import javax.xml.namespace.QName; |
import org.w3c.dom.Element; |
/** |
28,7 → 27,7 |
* <complexContent> |
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
* <sequence> |
* <any processContents='lax' namespace='http://www.eclipse.org/alf/schema/EventBase/1' maxOccurs="unbounded"/> |
* <any namespace='targetnamespace' maxOccurs="unbounded"/> |
* </sequence> |
* <anyAttribute/> |
* </restriction> |
67,7 → 66,6 |
* |
* <p> |
* Objects of the following type(s) are allowed in the list |
* {@link Element } |
* {@link Object } |
* |
* |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/EventBaseType.java |
---|
29,7 → 29,7 |
* <complexContent> |
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
* <sequence> |
* <element name="EventId" type="{http://www.eclipse.org/alf/schema/EventBase/1}SourceEventIdType"/> |
* <element name="EventId" type="{http://www.eclipse.org/alf/schema/EventBase/1}EventIdType"/> |
* <element name="Timestamp" type="{http://www.eclipse.org/alf/schema/EventBase/1}TimestampType"/> |
* <element name="EventType" type="{http://www.eclipse.org/alf/schema/EventBase/1}EventTypeType"/> |
* <element name="ObjectType" type="{http://www.eclipse.org/alf/schema/EventBase/1}ObjectTypeType"/> |
63,7 → 63,7 |
@XmlElement(name = "EventId", namespace = "http://www.eclipse.org/alf/schema/EventBase/1", required = true) |
protected String eventId; |
@XmlElement(name = "Timestamp", namespace = "http://www.eclipse.org/alf/schema/EventBase/1", required = true, nillable = true) |
@XmlElement(name = "Timestamp", namespace = "http://www.eclipse.org/alf/schema/EventBase/1", required = true) |
@XmlSchemaType(name = "dateTime") |
protected XMLGregorianCalendar timestamp; |
@XmlElement(name = "EventType", namespace = "http://www.eclipse.org/alf/schema/EventBase/1", required = true) |
/xservices/trunk/src/main/java/net/brutex/xservices/types/alfevent/ObjectFactory.java |
---|
24,7 → 24,7 |
@XmlRegistry |
public class ObjectFactory { |
private final static QName _ALFEventNoticeDoc_QNAME = new QName("http://www.eclipse.org/alf/schema/EventBase/1", "ALFEventNoticeDoc"); |
private final static QName _EventNotice_QNAME = new QName("http://www.eclipse.org/alf/schema/EventBase/1", "EventNotice"); |
/** |
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: net.brutex.xservices.types.alfevent |
34,14 → 34,6 |
} |
/** |
* Create an instance of {@link ALFSecurityType } |
* |
*/ |
public ALFSecurityType createALFSecurityType() { |
return new ALFSecurityType(); |
} |
/** |
* Create an instance of {@link ALFEventType } |
* |
*/ |
130,20 → 122,12 |
} |
/** |
* Create an instance of {@link ALFSecurityType.UsernameToken } |
* |
*/ |
public ALFSecurityType.UsernameToken createALFSecurityTypeUsernameToken() { |
return new ALFSecurityType.UsernameToken(); |
} |
/** |
* Create an instance of {@link JAXBElement }{@code <}{@link ALFEventType }{@code >}} |
* |
*/ |
@XmlElementDecl(namespace = "http://www.eclipse.org/alf/schema/EventBase/1", name = "ALFEventNoticeDoc") |
public JAXBElement<ALFEventType> createALFEventNoticeDoc(ALFEventType value) { |
return new JAXBElement<ALFEventType>(_ALFEventNoticeDoc_QNAME, ALFEventType.class, null, value); |
@XmlElementDecl(namespace = "http://www.eclipse.org/alf/schema/EventBase/1", name = "EventNotice") |
public JAXBElement<ALFEventType> createEventNotice(ALFEventType value) { |
return new JAXBElement<ALFEventType>(_EventNotice_QNAME, ALFEventType.class, null, value); |
} |
} |
/xservices/trunk/src/main/java/net/brutex/xservices/util/EventLogCleanerJob.java |
---|
File deleted |
/xservices/trunk/src/main/java/net/brutex/xservices/util/EventEmitter.java |
---|
51,11 → 51,10 |
* Move event table data to snapshot |
*/ |
try( Connection con = pool.getConnection(); |
Connection fcon = fpool.getConnection(); |
) { |
Connection con = null; |
Connection fcon = null; |
try { |
con = pool.getConnection(); |
con.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); |
con.setAutoCommit(false); |
Statement stmt = con.createStatement(); |
66,7 → 65,7 |
con.commit(); //all events moved from tbl_events to tbl_events_snap at this point |
fcon = fpool.getConnection(); |
PreparedStatement errorPrepSql = fcon.prepareStatement(moveErrorSQL); |
PreparedStatement del = con.prepareStatement(deleteSQL); |
84,8 → 83,7 |
long event_ts = rs.getLong(6); |
boolean bretry = false; |
//SimpleSoap ss = new SimpleSoap( url, id, IOUtils.toString(c.getAsciiStream()c.getCharacterStream())); |
SimpleSoap ss = new SimpleSoap(url, id, c.getSubString(1L, (int) c.length())); |
SimpleSoap ss = new SimpleSoap( url, id, IOUtils.toString(c.getCharacterStream())); |
int retry = 0; |
Reader response = null; |
String rsp = ""; |
154,8 → 152,16 |
} catch (IOException e) { |
log.error("Exception in SQL execution: {}", e.getMessage()); |
throw new RuntimeException(e); |
} finally { |
try { |
if(fcon!=null) fcon.close(); |
if(con!=null) con.close(); |
} catch (SQLException e) { |
log.error("Error closing the database connections: {}", e.getMessage()); |
throw new RuntimeException(e); |
} |
} |
} |
/** |
/xservices/trunk/src/main/java/net/brutex/xservices/util/EventmanagerConfiguration.java |
---|
8,8 → 8,6 |
import org.apache.commons.configuration2.PropertiesConfiguration; |
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; |
import org.apache.commons.configuration2.builder.PropertiesBuilderParametersImpl; |
import org.apache.commons.configuration2.event.ConfigurationEvent; |
import org.apache.commons.configuration2.event.EventListener; |
import org.apache.commons.configuration2.ex.ConfigurationException; |
import javax.servlet.ServletContext; |
41,8 → 39,6 |
private int interval; |
private String jdbc_memdb; |
private String jdbc_filedb; |
private boolean isEmitterActive = true; |
private int cleaner_interval; |
public synchronized EventmanagerConfiguration refreshConfig() { |
49,7 → 45,7 |
log.trace("Reading EventmanagerConfiguration from file eventmanager.properties."); |
FileBasedConfigurationBuilder<FileBasedConfiguration> builder = |
new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class) |
.configure(new PropertiesBuilderParametersImpl().setFileName("../eventmanager.properties")); |
.configure(new PropertiesBuilderParametersImpl().setFileName("eventmanager.properties")); |
try { |
Configuration config = builder.getConfiguration(); |
59,8 → 55,6 |
this.interval = config.getInt("interval", 10); |
this.jdbc_memdb = config.getString("memdb", "jdbc:h2:mem:lockdb;DB_CLOSE_DELAY=-1;"); |
this.jdbc_filedb = config.getString("fdb", "jdbc:h2:mem:lockdb;DB_CLOSE_DELAY=-1;"); |
this.isEmitterActive = config.getBoolean("emitter_active", true); |
this.cleaner_interval = config.getInt("cleaner_interval", 5); |
} catch (ConfigurationException e) { |
/xservices/trunk/src/main/java/net/brutex/xservices/util/MiscServiceServletContextListener.java |
---|
15,8 → 15,6 |
import java.sql.SQLException; |
import java.sql.Statement; |
import java.time.Instant; |
import java.time.temporal.ChronoUnit; |
import java.util.Date; |
import java.util.concurrent.atomic.AtomicLong; |
import static org.quartz.TriggerBuilder.newTrigger; |
50,12 → 48,12 |
*/ |
private static JdbcConnectionPool getDbPool(String dbConnectString) { |
JdbcConnectionPool p = JdbcConnectionPool.create(dbConnectString, "", ""); |
p.setMaxConnections(256); |
p.setLoginTimeout(20); |
try (Connection c = p.getConnection();){ |
p.setMaxConnections(16); |
p.setLoginTimeout(5); |
try { |
Connection c = p.getConnection(); |
Statement s = c.createStatement(); |
s.execute(dbinit); |
c.commit(); |
log.trace("Running SQL against database '{}': '{}'", dbConnectString, dbinit); |
c.close(); |
log.debug("Successfully created schema for database 'Brutex' at '{}'.", dbConnectString); |
74,7 → 72,6 |
log.debug("Active jobs to be terminated: {}", scheduler.getCurrentlyExecutingJobs()); |
JobKey key = JobKey.jobKey("ALFEmitter"); |
JobKey cleanerkey = JobKey.jobKey("EventLogCleaner"); |
synchronized (scheduler) { |
if (!scheduler.isShutdown() && scheduler.checkExists(key) ) { |
scheduler.interrupt(key); |
81,11 → 78,6 |
scheduler.deleteJob(key); |
log.info("Gracefully stopped the ALFEventEmitter job."); |
} |
if (!scheduler.isShutdown() && scheduler.checkExists(cleanerkey) ) { |
scheduler.interrupt(cleanerkey); |
scheduler.deleteJob(cleanerkey); |
log.info("Gracefully stopped the ALFEventEmitter job."); |
} |
if (!scheduler.isShutdown()) { |
scheduler.shutdown(true); |
} |
106,19 → 98,12 |
Connection con = fdbpool.getConnection(); |
Statement s = con.createStatement(); |
final String insert = "INSERT INTO brutex.tbl_events SELECT * from MEM_INBOUND UNION SELECT " + "btx_event_type, btx_id, btx_obj_type, btx_obj_id, btx_timestamp, btx_event from MEM_OUTBOUND;"; |
final String insert = "INSERT INTO brutex.tbl_events SELECT * from LINK UNION SELECT " + "btx_event_type, btx_id, btx_obj_type, btx_obj_id, btx_timestamp, btx_event from LINK2;"; |
s.execute(insert); |
int count = s.getUpdateCount(); |
log.info("Persisted {} active event rows in file-based database.", count); |
final String save_all = "INSERT INTO brutex.tbl_events_all SELECT * from MEM_ALL_EVENTS;"; |
s.execute(save_all); |
count = s.getUpdateCount(); |
log.info("Persisted {} event rows from all_events log in file-based database", count); |
log.info("Persisted {} rows in file-based database.", count); |
log.info("Shutting down in-memory database. Closing file-based database. Please wait ..."); |
s.execute("SHUTDOWN;"); |
con.close(); |
log.info("Shutting down databases complete."); |
} catch (SQLException e) { |
156,8 → 141,9 |
//Load events from file based database into in-memory database |
try { |
log.info("Start recovery of previously unsend alf events. Trying to load them into in-memory database."); |
final String link = getLinkSQL(); |
final String recoverSQL = "INSERT INTO MEM_INBOUND DIRECT SELECT * FROM brutex.tbl_events;"; |
final String link = "CREATE LINKED TABLE IF NOT EXISTS LINK('org.h2.Driver', '"+configuration.getJdbc_memdb()+"', '', '', 'brutex.tbl_events'); " + |
"CREATE LINKED TABLE IF NOT EXISTS LINK2('org.h2.Driver', '"+configuration.getJdbc_memdb()+"', '', '', 'brutex.tbl_events_snap');"; |
final String recoverSQL = "INSERT INTO LINK DIRECT SELECT * FROM brutex.tbl_events;"; |
final String truncate = "TRUNCATE TABLE brutex.tbl_events;"; |
int count = 0; |
Connection con = fdbpool.getConnection(); |
177,26 → 163,10 |
throw new RuntimeException(e); |
} |
//Start initial run of the emitter |
if(configuration.isEmitterActive()) { |
startEmitterImmediate(egres, (Scheduler) context.getAttribute("scheduler")); |
} |
//Start mem db log cleaner |
if(configuration.getCleaner_interval()>0) { |
startEventLogCleaner((Scheduler) context.getAttribute("scheduler")); |
} |
} |
private String getLinkSQL() { |
final String dbDriverClass = "org.h2.Driver"; |
final String link = "CREATE LINKED TABLE IF NOT EXISTS MEM_INBOUND('"+dbDriverClass+"', '"+configuration.getJdbc_memdb()+"', '', '', 'brutex.tbl_events'); " + |
"CREATE LINKED TABLE IF NOT EXISTS MEM_OUTBOUND('"+dbDriverClass+"', '"+configuration.getJdbc_memdb()+"', '', '', 'brutex.tbl_events_snap'); " + |
"CREATE LINKED TABLE IF NOT EXISTS MEM_ALL_EVENTS('"+dbDriverClass+"', '"+configuration.getJdbc_memdb()+"', '', '', 'brutex.tbl_events_all') AUTOCOMMIT OFF; " + |
""; |
return link; |
} |
private synchronized void startEmitterImmediate(AtomicLong egres, Scheduler scheduler) { |
private synchronized void startEmitterImmediate(AtomicLong egres_counter, Scheduler scheduler) { |
try { |
if (!scheduler.checkExists(JobKey.jobKey("ALFEmitter"))) { |
JobDetail job2 = JobBuilder.newJob(EventEmitter.class).withIdentity("ALFEmitter").build(); |
203,7 → 173,7 |
job2.getJobDataMap().put("mdbConnection", mempool); |
job2.getJobDataMap().put("fdbConnection", fdbpool); |
job2.getJobDataMap().put("run_key", Instant.now().toEpochMilli()); |
job2.getJobDataMap().put("egres_counter", egres); |
job2.getJobDataMap().put("egres_counter", egres_counter); |
job2.getJobDataMap().put(EventmanagerConfiguration.KEY, EventmanagerConfiguration.getInstance()); |
SimpleTrigger t = (SimpleTrigger) newTrigger().withIdentity("ALFEmitter").startNow().build(); |
scheduler.scheduleJob(job2, t); |
213,27 → 183,6 |
} |
} |
private void startEventLogCleaner(Scheduler scheduler) { |
try { |
if (!scheduler.checkExists(JobKey.jobKey("EventLogCleaner"))) { |
JobDetail job2 = JobBuilder.newJob(EventLogCleanerJob.class).withIdentity("EventLogCleaner").build(); |
job2.getJobDataMap().put("mdbConnection", mempool); |
job2.getJobDataMap().put("fdbConnection", fdbpool); |
job2.getJobDataMap().put("run_key", Instant.now().toEpochMilli()); |
job2.getJobDataMap().put(EventmanagerConfiguration.KEY, EventmanagerConfiguration.getInstance()); |
SimpleTrigger t = (SimpleTrigger) newTrigger().withIdentity("EventLogCleaner") |
.withSchedule(SimpleScheduleBuilder.simpleSchedule() |
.withIntervalInMinutes(configuration.getCleaner_interval()) |
.repeatForever()) |
.startAt(Date.from(Instant.now().plus(configuration.getCleaner_interval(), ChronoUnit.MINUTES))) |
.build(); |
scheduler.scheduleJob(job2, t); |
} |
} catch (SchedulerException ex) { |
log.error("Could not start EventLogCleaner to process existing queue directly after startup: {}", ex.getMessage()); |
} |
} |
private void readConfiguration(ServletContext ctx) { |
/* Configure ServletContext attributes using configuration object*/ |
EventmanagerConfiguration c = EventmanagerConfiguration.getInstance().refreshConfig(); |
/xservices/trunk/src/main/java/net/brutex/xservices/util/SimpleSoap.java |
---|
22,14 → 22,11 |
import org.apache.http.client.entity.EntityBuilder; |
import org.apache.http.client.fluent.Request; |
import org.apache.http.client.fluent.Response; |
import org.apache.http.entity.ContentType; |
import java.io.BufferedReader; |
import java.io.IOException; |
import java.io.InputStreamReader; |
import java.io.Reader; |
import java.nio.charset.Charset; |
import java.nio.charset.StandardCharsets; |
import java.util.concurrent.atomic.AtomicBoolean; |
72,13 → 69,11 |
public Reader sendSoap(boolean isDropResponse) { |
Reader response = null; |
long start = System.currentTimeMillis(); |
EntityBuilder entitybuilder = EntityBuilder.create(); |
entitybuilder.setContentEncoding("UTF-8"); |
entitybuilder.setText(soapBody); |
HttpEntity entity = entitybuilder.build(); |
HttpEntity entity = EntityBuilder.create() |
.setText(soapBody) |
.setContentType(ContentType.create("text/xml", StandardCharsets.UTF_8)) |
.setContentEncoding("UTF-8") |
.build(); |
log.trace("Sending event '{}' to target ALF Event Manager.", id); |
if(isInterrupted.get()) return null; |
86,7 → 81,7 |
try { |
Response resp = Request.Post(url) |
.addHeader("Accept", "text/xml") |
//.addHeader("Content-Type", "text/xml; charset=utf-8") |
.addHeader("Content-Type", "text/xml; charset=utf-8") |
.addHeader("SOAPAction", "") |
.body(entity).execute(); |
/xservices/trunk/src/main/java/net/brutex/xservices/ws/impl/MiscServiceImpl.java |
---|
41,7 → 41,6 |
import javax.xml.bind.JAXBElement; |
import javax.xml.bind.JAXBException; |
import javax.xml.bind.Marshaller; |
import javax.xml.namespace.QName; |
import javax.xml.ws.WebServiceContext; |
import javax.xml.ws.handler.MessageContext; |
import java.io.StringReader; |
70,7 → 69,6 |
@Resource |
private WebServiceContext context; |
public MiscServiceImpl() throws SchedulerException { |
} |
176,6 → 174,7 |
public BigInteger lock(String id, String objectId) throws XServicesFault { |
final String conString = "jdbc:h2:mem:lockdb;DB_CLOSE_DELAY=10;" + |
"INIT=CREATE SCHEMA IF NOT EXISTS brutex\\;" + |
// "SET SCHEMA brutex\\;" + |
228,8 → 227,6 |
final Instant d = Instant.now(); |
final long ts = d.toEpochMilli(); |
MessageContext cont = context.getMessageContext(); |
//Get Parameters from the Servlet Context |
final ServletContext servletContext = |
(ServletContext) context.getMessageContext().get(MessageContext.SERVLET_CONTEXT); |
254,33 → 251,29 |
log.debug("Event id '{}', type '{}' received for object '{}' with object_id '{}'.", |
eventId, eventType, objectType, objectId); |
final String mergeStatememt = "SELECT btx_id FROM OLD TABLE (MERGE INTO brutex.tbl_events " + |
final String mergeStatememt = "MERGE INTO brutex.tbl_events " + |
"KEY (btx_event_type, btx_obj_type, btx_obj_id) " + |
"VALUES (?,?,?,?,?,?));"; |
"VALUES (?,?,?,?,?,?);"; |
final String insertAll = "INSERT INTO brutex.tbl_events_all VALUES (?,?,?,?,?,?,?)"; |
try (Connection con = pool.getConnection()) { |
try { |
Marshaller m = JAXBContext.newInstance(ALFEventType.class).createMarshaller(); |
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); |
m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); |
m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); |
JAXBElement<ALFEventType> e = of.createALFEventNoticeDoc(event); |
JAXBElement<ALFEventType> e = of.createEventNotice(event); |
StringWriter sw = new StringWriter(); |
m.marshal(e, sw); |
StringBuilder sb = new StringBuilder(); |
sb.append(" <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " + |
"xmlns:ns=\"http://www.eclipse.org/alf/schema/EventBase/1\">\n"); |
sb.append("<soapenv:Body>\n"); |
sb.append("<ns:EventNotice>\n"); |
sb.append(sw); |
sb.append("</ns:EventNotice>\n"); |
sb.append("</soapenv:Body>"); |
sb.append("</soapenv:Envelope>"); |
Connection con = pool.getConnection(); |
PreparedStatement prep = con.prepareStatement(mergeStatememt); |
prep.setString(1, eventType); |
prep.setString(2, eventId); |
288,35 → 281,12 |
prep.setString(4, objectId); |
prep.setLong(5, ts); |
prep.setClob(6, new StringReader(sb.toString())); |
ResultSet r = prep.executeQuery(); |
con.commit(); |
String supersed_id = null; |
if (r.next()) { |
supersed_id = r.getString(1); |
log.trace("Event '{}' superseded event '{}'", eventId, supersed_id); |
} else { |
log.trace("Event '{}' inserted into outgoing queue.", eventId); |
} |
/* Write all into permanent storage */ |
//Connection fcon = fpool.getConnection(); |
prep = con.prepareStatement(insertAll); |
prep.setString(1, eventType); |
prep.setString(2, eventId); |
prep.setString(3, objectType); |
prep.setString(4, objectId); |
prep.setLong(5, ts); |
prep.setString(6, supersed_id); |
prep.setClob(7, new StringReader(sb.toString())); |
prep.execute(); |
con.commit(); |
con.close(); |
ingres_counter.incrementAndGet(); |
if (conf.isEmitterActive()) { |
synchronized (scheduler) { |
if (!scheduler.checkExists(JobKey.jobKey("ALFEmitter"))) { |
JobDetail job2 = JobBuilder.newJob(EventEmitter.class) |
337,7 → 307,6 |
scheduler.scheduleJob(job2, t); |
} |
} |
} |
} catch (JAXBException | SQLException | SchedulerException e) { |
log.error(e.getMessage()); |
throw new XServicesFault(e); |
/xservices/trunk/src/main/java/net/brutex/xservices/ws/MiscService.java |
---|
74,7 → 74,6 |
public abstract BigInteger lock(@WebParam(name="id") @XmlElement(nillable = false) String id, |
@WebParam(name="objectId") @XmlElement(nillable = false) String objectId) throws XServicesFault; |
@WebMethod(operationName="", action = "EventNotice") |
@SOAPBinding(use = SOAPBinding.Use.LITERAL, style = SOAPBinding.Style.DOCUMENT, parameterStyle = SOAPBinding.ParameterStyle.BARE) |
public abstract ALFEventResponseType mergeALFEvent(@WebParam(name="ALFEventNoticeDoc", targetNamespace = "http://www.eclipse.org/alf/schema/EventBase/1") ALFEventType event) throws XServicesFault; |
@WebMethod(operationName="EventNotice") |
public abstract ALFEventResponseType mergeALFEvent(@WebParam(name="EventNotice", targetNamespace = "http://www.eclipse.org/alf/schema/EventBase/1") ALFEventType event) throws XServicesFault; |
} |