mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
adding fixes to the flow
This commit is contained in:
parent
56f93161f0
commit
3744a7cfc7
@ -59,6 +59,7 @@
|
||||
javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional,
|
||||
org.wso2.carbon.context,
|
||||
org.wso2.carbon.utils.*,
|
||||
org.wso2.carbon.ndatasource.core,
|
||||
org.w3c.dom,
|
||||
org.apache.velocity;version="${velocity.version}",
|
||||
org.apache.velocity.app;version="${velocity.version}",
|
||||
@ -168,6 +169,16 @@
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>log4j</artifactId>
|
||||
<groupId>log4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@ -30,7 +30,6 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.File;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Hashtable;
|
||||
@ -68,7 +67,7 @@ public class HeartBeatBeaconUtils {
|
||||
return (DataSource) InitialContext.doLookup(dataSourceName);
|
||||
}
|
||||
final InitialContext context = new InitialContext(jndiProperties);
|
||||
return (DataSource) context.lookup(dataSourceName);
|
||||
return (DataSource) context.doLookup(dataSourceName);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error in looking up data source: " + e.getMessage(), e);
|
||||
}
|
||||
@ -77,20 +76,10 @@ public class HeartBeatBeaconUtils {
|
||||
|
||||
public static ServerContext getServerDetails() throws UnknownHostException, SocketException {
|
||||
InetAddress localHost = InetAddress.getLocalHost();
|
||||
NetworkInterface ni = NetworkInterface.getByInetAddress(localHost);
|
||||
byte[] hardwareAddress = ni.getHardwareAddress();
|
||||
String[] hexadecimal = new String[hardwareAddress.length];
|
||||
for (int i = 0; i < hardwareAddress.length; i++) {
|
||||
hexadecimal[i] = String.format("%02X", hardwareAddress[i]);
|
||||
}
|
||||
String macAddress = String.join("-", hexadecimal);
|
||||
int iotsCorePort = Integer.parseInt(System.getProperty("iot.core.https.port"));
|
||||
|
||||
ServerContext ctx = new ServerContext();
|
||||
ctx.setHostName(localHost.getHostName());
|
||||
ctx.setMacAddress(macAddress);
|
||||
ctx.setCarbonServerPort(iotsCorePort);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
@ -35,6 +35,7 @@ import java.io.File;
|
||||
@XmlRootElement(name = "HeartBeatBeaconConfig")
|
||||
public class HeartBeatBeaconConfig {
|
||||
|
||||
private boolean enabled;
|
||||
private int notifierFrequency;
|
||||
private int notifierDelay;
|
||||
private int serverTimeOutIntervalInSeconds;
|
||||
@ -44,7 +45,7 @@ public class HeartBeatBeaconConfig {
|
||||
private static HeartBeatBeaconConfig config;
|
||||
|
||||
private static final String HEART_BEAT_NOTIFIER_CONFIG_PATH =
|
||||
CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "heart-beat-config.xml";
|
||||
CarbonUtils.getCarbonConfigDirPath() + File.separator + "heart-beat-config.xml";
|
||||
|
||||
private HeartBeatBeaconConfig() {
|
||||
}
|
||||
@ -102,6 +103,15 @@ public class HeartBeatBeaconConfig {
|
||||
this.dataSourceConfig = dataSourceConfig;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Enable", required = true)
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public static void init() throws HeartBeatBeaconConfigurationException {
|
||||
try {
|
||||
File emailSenderConfig = new File(HEART_BEAT_NOTIFIER_CONFIG_PATH);
|
||||
|
||||
@ -167,7 +167,6 @@ public class HeartBeatBeaconDAOFactory {
|
||||
currentConnection.remove();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolve data source from the data source definition
|
||||
*
|
||||
@ -190,7 +189,7 @@ public class HeartBeatBeaconDAOFactory {
|
||||
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
|
||||
jndiConfig.getJndiProperties();
|
||||
if (jndiPropertyList != null) {
|
||||
Hashtable<Object, Object> jndiProperties = new Hashtable<>();
|
||||
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
|
||||
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||
jndiProperties.put(prop.getName(), prop.getValue());
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -46,23 +47,21 @@ public class GenericHeartBeatDAOImpl implements HeartBeatDAO {
|
||||
String uuid = null;
|
||||
try {
|
||||
Connection conn = HeartBeatBeaconDAOFactory.getConnection();
|
||||
String serverUUID = UUID.randomUUID().toString();
|
||||
|
||||
String sql;
|
||||
sql = "INSERT INTO SERVER_HEART_BEAT_EVENTS(HOST_NAME, MAC, UUID, SERVER_PORT) VALUES (?, ?, ?, ?)";
|
||||
stmt = conn.prepareStatement(sql, new String[]{"UUID"});
|
||||
sql = "INSERT INTO SERVER_HEART_BEAT_EVENTS(HOST_NAME, UUID, SERVER_PORT) VALUES (?, ?, ?)";
|
||||
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
||||
stmt.setString(1, ctx.getHostName());
|
||||
stmt.setString(2, ctx.getMacAddress());
|
||||
stmt.setString(3, UUID.randomUUID().toString());
|
||||
stmt.setInt(4, ctx.getCarbonServerPort());
|
||||
stmt.setString(2, serverUUID);
|
||||
stmt.setInt(3, ctx.getCarbonServerPort());
|
||||
|
||||
stmt.executeUpdate();
|
||||
ResultSet result = stmt.getGeneratedKeys();
|
||||
if (result.next()){
|
||||
uuid = result.getString("UUID");
|
||||
if(stmt.executeUpdate() > 0){
|
||||
uuid = serverUUID;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new HeartBeatDAOException("Error occurred while persisting server context for : '" +
|
||||
"mac '" + ctx.getMacAddress() + "' " +
|
||||
"port '" + ctx.getCarbonServerPort() + "' " +
|
||||
"hostname : '" + ctx.getHostName() + "' ", e);
|
||||
} finally {
|
||||
HeartBeatBeaconDAOUtil.cleanupResources(stmt, null);
|
||||
@ -97,11 +96,10 @@ public class GenericHeartBeatDAOImpl implements HeartBeatDAO {
|
||||
String uuid = null;
|
||||
try {
|
||||
Connection conn = HeartBeatBeaconDAOFactory.getConnection();
|
||||
String sql = "SELECT UUID FROM SERVER_HEART_BEAT_EVENTS WHERE HOST_NAME = ? AND MAC = ? AND SERVER_PORT = ?";
|
||||
String sql = "SELECT UUID FROM SERVER_HEART_BEAT_EVENTS WHERE HOST_NAME = ? AND SERVER_PORT = ?";
|
||||
stmt = conn.prepareStatement(sql, new String[]{"UUID"});
|
||||
stmt.setString(1, ctx.getHostName());
|
||||
stmt.setString(2, ctx.getMacAddress());
|
||||
stmt.setInt(3, ctx.getCarbonServerPort());
|
||||
stmt.setInt(2, ctx.getCarbonServerPort());
|
||||
|
||||
resultSet = stmt.executeQuery();
|
||||
if (resultSet.next()){
|
||||
@ -109,7 +107,7 @@ public class GenericHeartBeatDAOImpl implements HeartBeatDAO {
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new HeartBeatDAOException("Error occurred while retrieving meta information for heart beat event from " +
|
||||
"mac '" + ctx.getMacAddress() + "' " +
|
||||
"port '" + ctx.getCarbonServerPort() + "' " +
|
||||
"hostname : '" + ctx.getHostName() + "' ", e);
|
||||
} finally {
|
||||
HeartBeatBeaconDAOUtil.cleanupResources(stmt, resultSet);
|
||||
@ -124,7 +122,7 @@ public class GenericHeartBeatDAOImpl implements HeartBeatDAO {
|
||||
Map<String, ServerContext> ctxList = new HashMap<>();
|
||||
try {
|
||||
Connection conn = HeartBeatBeaconDAOFactory.getConnection();
|
||||
String sql = "SELECT (@row_number:=@row_number + 1) AS IDX, UUID, HOST_NAME, MAC, SERVER_PORT from " +
|
||||
String sql = "SELECT (@row_number:=@row_number + 1) AS IDX, UUID, HOST_NAME, SERVER_PORT from " +
|
||||
"SERVER_HEART_BEAT_EVENTS, (SELECT @row_number:=-1) AS TEMP " +
|
||||
"WHERE LAST_UPDATED_TIMESTAMP > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL ? SECOND) " +
|
||||
"ORDER BY UUID";
|
||||
|
||||
@ -85,7 +85,6 @@ public final class HeartBeatBeaconDAOUtil {
|
||||
ctx.setIndex(resultSet.getInt("IDX"));
|
||||
ctx.setUuid(resultSet.getString("UUID"));
|
||||
ctx.setHostName(resultSet.getString("HOST_NAME"));
|
||||
ctx.setMacAddress(resultSet.getString("MAC"));
|
||||
ctx.setCarbonServerPort(resultSet.getInt("SERVER_PORT"));
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ package io.entgra.server.bootup.heartbeat.beacon.dto;
|
||||
public class ServerContext {
|
||||
|
||||
private String hostName;
|
||||
private String macAddress;
|
||||
private int carbonServerPort;
|
||||
private String uuid;
|
||||
private int index;
|
||||
@ -34,14 +33,6 @@ public class ServerContext {
|
||||
this.hostName = hostName;
|
||||
}
|
||||
|
||||
public String getMacAddress() {
|
||||
return macAddress;
|
||||
}
|
||||
|
||||
public void setMacAddress(String macAddress) {
|
||||
this.macAddress = macAddress;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@ -27,10 +27,17 @@ import io.entgra.server.bootup.heartbeat.beacon.service.HeartBeatManagementServi
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
import org.wso2.carbon.ndatasource.core.DataSourceService;
|
||||
|
||||
/**
|
||||
* @scr.component name="io.entgra.server.bootup.heartbeat.beacon.heartbeatBeaconComponent"
|
||||
* immediate="true"
|
||||
* @scr.reference name="org.wso2.carbon.ndatasource"
|
||||
* interface="org.wso2.carbon.ndatasource.core.DataSourceService"
|
||||
* cardinality="1..1"
|
||||
* policy="dynamic"
|
||||
* bind="setDataSourceService"
|
||||
* unbind="unsetDataSourceService"
|
||||
*/
|
||||
public class HeartBeatBeaconComponent {
|
||||
|
||||
@ -42,21 +49,24 @@ public class HeartBeatBeaconComponent {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Initializing email sender core bundle");
|
||||
}
|
||||
this.registerHeartBeatServices(componentContext);
|
||||
|
||||
//heart beat notifier configuration */
|
||||
HeartBeatBeaconConfig.init();
|
||||
|
||||
if(HeartBeatBeaconConfig.getInstance().isEnabled()) {
|
||||
DataSourceConfig dsConfig = HeartBeatBeaconConfig.getInstance().getDataSourceConfig();
|
||||
HeartBeatBeaconDAOFactory.init(dsConfig);
|
||||
|
||||
this.registerHeartBeatServices(componentContext);
|
||||
|
||||
//Setting up executors to notify heart beat status */
|
||||
HeartBeatInternalUtils.setUpNotifiers(HeartBeatBeaconUtils.getServerDetails());
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Email sender core bundle has been successfully initialized");
|
||||
log.debug("Heart Beat Notifier bundle has been successfully initialized");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error("Error occurred while initializing email sender core bundle", e);
|
||||
log.error("Error occurred while initializing Heart Beat Notifier bundle", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,4 +84,16 @@ public class HeartBeatBeaconComponent {
|
||||
componentContext.getBundleContext().registerService(HeartBeatManagementService.class, heartBeatServiceProvider, null);
|
||||
}
|
||||
|
||||
protected void setDataSourceService(DataSourceService dataSourceService) {
|
||||
/* This is to avoid mobile device management component getting initialized before the underlying datasources
|
||||
are registered */
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Data source service set to mobile service component");
|
||||
}
|
||||
}
|
||||
|
||||
protected void unsetDataSourceService(DataSourceService dataSourceService) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ package io.entgra.server.bootup.heartbeat.beacon.internal;
|
||||
|
||||
import io.entgra.server.bootup.heartbeat.beacon.config.HeartBeatBeaconConfig;
|
||||
import io.entgra.server.bootup.heartbeat.beacon.HeartBeatBeaconConfigurationException;
|
||||
import io.entgra.server.bootup.heartbeat.beacon.dao.HeartBeatBeaconDAOFactory;
|
||||
import io.entgra.server.bootup.heartbeat.beacon.dto.HeartBeatEvent;
|
||||
import io.entgra.server.bootup.heartbeat.beacon.dto.ServerContext;
|
||||
import io.entgra.server.bootup.heartbeat.beacon.exception.HeartBeatManagementException;
|
||||
@ -66,7 +67,7 @@ public class HeartBeatInternalUtils {
|
||||
CONFIG.getNotifierFrequency() != 0 ? CONFIG.getNotifierFrequency() : DEFAULT__NOTIFIER_INTERVAL,
|
||||
TimeUnit.SECONDS);
|
||||
} catch (HeartBeatManagementException e) {
|
||||
throw new HeartBeatBeaconConfigurationException("Error occured while updating initial server context.");
|
||||
throw new HeartBeatBeaconConfigurationException("Error occured while updating initial server context.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ import io.entgra.server.bootup.heartbeat.beacon.exception.HeartBeatManagementExc
|
||||
import io.entgra.server.bootup.heartbeat.beacon.dto.ServerContext;
|
||||
import io.entgra.server.bootup.heartbeat.beacon.internal.HeartBeatBeaconDataHolder;
|
||||
import org.wso2.carbon.device.mgt.common.ServerCtxInfo;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.TransactionManagementException;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
@ -39,6 +40,7 @@ public class HeartBeatManagementServiceImpl implements HeartBeatManagementServic
|
||||
int hashIndex = -1;
|
||||
ServerContext localServerCtx = null;
|
||||
ServerCtxInfo serverCtxInfo = null;
|
||||
if(HeartBeatBeaconConfig.getInstance().isEnabled()) {
|
||||
try {
|
||||
HeartBeatBeaconDAOFactory.openConnection();
|
||||
heartBeatDAO = HeartBeatBeaconDAOFactory.getHeartBeatDAO();
|
||||
@ -48,7 +50,7 @@ public class HeartBeatManagementServiceImpl implements HeartBeatManagementServic
|
||||
int cumilativeTimeOut = timeOutIntervalInSeconds + timeSkew;
|
||||
String localServerUUID = HeartBeatBeaconDataHolder.getInstance().getLocalServerUUID();
|
||||
Map<String, ServerContext> serverCtxMap = heartBeatDAO.getActiveServerDetails(cumilativeTimeOut);
|
||||
if(!serverCtxMap.isEmpty()) {
|
||||
if (!serverCtxMap.isEmpty()) {
|
||||
localServerCtx = serverCtxMap.get(localServerUUID);
|
||||
if (localServerCtx != null) {
|
||||
hashIndex = localServerCtx.getIndex();
|
||||
@ -64,6 +66,10 @@ public class HeartBeatManagementServiceImpl implements HeartBeatManagementServic
|
||||
} finally {
|
||||
HeartBeatBeaconDAOFactory.closeConnection();
|
||||
}
|
||||
} else {
|
||||
String msg = "Heart Beat Configuration Disabled. Server Context Information Not available.";
|
||||
throw new HeartBeatManagementException(msg);
|
||||
}
|
||||
return serverCtxInfo;
|
||||
}
|
||||
|
||||
@ -71,23 +77,30 @@ public class HeartBeatManagementServiceImpl implements HeartBeatManagementServic
|
||||
public String updateServerContext(ServerContext ctx) throws HeartBeatManagementException {
|
||||
HeartBeatDAO heartBeatDAO;
|
||||
String uuid = null;
|
||||
if(HeartBeatBeaconConfig.getInstance().isEnabled()) {
|
||||
try {
|
||||
HeartBeatBeaconDAOFactory.openConnection();
|
||||
HeartBeatBeaconDAOFactory.beginTransaction();
|
||||
heartBeatDAO = HeartBeatBeaconDAOFactory.getHeartBeatDAO();
|
||||
|
||||
uuid = heartBeatDAO.retrieveExistingServerCtx(ctx);
|
||||
if(uuid == null){
|
||||
if (uuid == null) {
|
||||
uuid = heartBeatDAO.recordServerCtx(ctx);
|
||||
HeartBeatBeaconDAOFactory.commitTransaction();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while opening a connection to the underlying data source";
|
||||
throw new HeartBeatManagementException(msg, e);
|
||||
} catch (HeartBeatDAOException e) {
|
||||
String msg = "Error Occured while retrieving active server count.";
|
||||
String msg = "Error Occured while retrieving server context.";
|
||||
throw new HeartBeatManagementException(msg, e);
|
||||
} catch (TransactionManagementException e) {
|
||||
HeartBeatBeaconDAOFactory.rollbackTransaction();
|
||||
String msg = "Error occurred while updating server context. Issue in opening a connection to the underlying data source";
|
||||
throw new HeartBeatManagementException(msg, e);
|
||||
} finally {
|
||||
HeartBeatBeaconDAOFactory.closeConnection();
|
||||
}
|
||||
} else {
|
||||
String msg = "Heart Beat Configuration Disabled. Updating Server Context Failed.";
|
||||
throw new HeartBeatManagementException(msg);
|
||||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@ -96,19 +109,27 @@ public class HeartBeatManagementServiceImpl implements HeartBeatManagementServic
|
||||
public boolean recordHeartBeat(HeartBeatEvent event) throws HeartBeatManagementException {
|
||||
HeartBeatDAO heartBeatDAO;
|
||||
boolean operationSuccess = false;
|
||||
if (HeartBeatBeaconConfig.getInstance().isEnabled()) {
|
||||
try {
|
||||
HeartBeatBeaconDAOFactory.openConnection();
|
||||
HeartBeatBeaconDAOFactory.beginTransaction();
|
||||
heartBeatDAO = HeartBeatBeaconDAOFactory.getHeartBeatDAO();
|
||||
operationSuccess = heartBeatDAO.recordHeatBeat(event);
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while opening a connection to the underlying data source";
|
||||
throw new HeartBeatManagementException(msg, e);
|
||||
HeartBeatBeaconDAOFactory.commitTransaction();
|
||||
} catch (HeartBeatDAOException e) {
|
||||
String msg = "Error Occured while retrieving active server count.";
|
||||
String msg = "Error occurred while recording heart beat.";
|
||||
throw new HeartBeatManagementException(msg, e);
|
||||
} catch (TransactionManagementException e) {
|
||||
HeartBeatBeaconDAOFactory.rollbackTransaction();
|
||||
String msg = "Error occurred performing heart beat record transaction. " +
|
||||
"Transaction rolled back.";
|
||||
throw new HeartBeatManagementException(msg, e);
|
||||
} finally {
|
||||
HeartBeatBeaconDAOFactory.closeConnection();
|
||||
}
|
||||
} else {
|
||||
String msg = "Heart Beat Configuration Disabled. Recording Heart Beat Failed.";
|
||||
throw new HeartBeatManagementException(msg);
|
||||
}
|
||||
return operationSuccess;
|
||||
}
|
||||
|
||||
|
||||
@ -87,7 +87,6 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@ -115,42 +114,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Creating Heart Beat Management schema -->
|
||||
<id>create-heart-beat-mgt-schema</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<echo message="########### Create Heart Beat Management H2 Schema ###########" />
|
||||
<property name="db.dir" value="target/maven-shared-archive-resources/database" />
|
||||
<property name="userid" value="wso2carbon" />
|
||||
<property name="password" value="wso2carbon" />
|
||||
<property name="dbURL" value="jdbc:h2:file:${basedir}/${db.dir}/HeartBeat_DB;DB_CLOSE_ON_EXIT=FALSE" />
|
||||
|
||||
<mkdir dir="${basedir}/${db.dir}" />
|
||||
|
||||
<sql driver="org.h2.Driver" url="${dbURL}" userid="${userid}" password="${password}" autocommit="true" onerror="continue">
|
||||
<classpath refid="maven.dependency.classpath" />
|
||||
<classpath refid="maven.compile.classpath" />
|
||||
<classpath refid="maven.runtime.classpath" />
|
||||
|
||||
<fileset file="${basedir}/src/main/resources/dbscripts/heart-beat/h2.sql" />
|
||||
</sql>
|
||||
<echo message="##################### END ####################" />
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.wso2.maven</groupId>
|
||||
<artifactId>carbon-p2-plugin</artifactId>
|
||||
|
||||
@ -19,9 +19,10 @@
|
||||
-->
|
||||
|
||||
<HeartBeatBeaconConfig>
|
||||
<DataSourceConfiguration type="heart-beat">
|
||||
<Enable>true</Enable>
|
||||
<DataSourceConfiguration>
|
||||
<JndiLookupDefinition>
|
||||
<Name>jdbc/ServerHeartBeat_DS</Name>
|
||||
<Name>jdbc/HeartBeat_DS</Name>
|
||||
</JndiLookupDefinition>
|
||||
</DataSourceConfiguration>
|
||||
<NotifierInitialDelayInSeconds>30</NotifierInitialDelayInSeconds>
|
||||
|
||||
@ -16,25 +16,23 @@
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<datasources-configuration>
|
||||
<datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration">
|
||||
<providers>
|
||||
<provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider>
|
||||
</providers>
|
||||
|
||||
<datasources>
|
||||
<datasource>
|
||||
<name>jdbc/ServerHeartBeat_DS</name>
|
||||
<description>The datasource used for recording server Heart Beats</description>
|
||||
<name>HeartBeat_DS</name>
|
||||
<description>The datasource Server Heart Beat</description>
|
||||
<jndiConfig>
|
||||
<name>jdbc/ServerHeartBeat_DS</name>
|
||||
<name>jdbc/HeartBeat_DS</name>
|
||||
</jndiConfig>
|
||||
<definition type="RDBMS">
|
||||
<configuration>
|
||||
<url>jdbc:h2:repository/database/HeartBeat_DB;DB_CLOSE_ON_EXIT=FALSE</url>
|
||||
<username>wso2carbon</username>
|
||||
<password>wso2carbon</password>
|
||||
<driverClassName>org.h2.Driver</driverClassName>
|
||||
<url>jdbc:mysql://localhost:3306/heart_beat</url>
|
||||
<username>root</username>
|
||||
<password>root</password>
|
||||
<driverClassName>com.mysql.jdbc.Driver</driverClassName>
|
||||
<maxActive>50</maxActive>
|
||||
<maxWait>60000</maxWait>
|
||||
<testOnBorrow>true</testOnBorrow>
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
CREATE TABLE IF NOT EXISTS SERVER_HEART_BEAT_EVENTS (
|
||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||
HOST_NAME VARCHAR(100) NOT NULL,
|
||||
MAC VARCHAR(100) NOT NULL,
|
||||
UUID VARCHAR(100) NOT NULL,
|
||||
SERVER_PORT INTEGER NOT NULL,
|
||||
LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
||||
@ -6,7 +6,6 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[S
|
||||
CREATE TABLE SERVER_HEART_BEAT_EVENTS (
|
||||
ID INT NOT NULL AUTO_INCREMENT,
|
||||
HOST_NAME VARCHAR(100) NOT NULL,
|
||||
MAC VARCHAR(100) NOT NULL,
|
||||
UUID VARCHAR(100) NOT NULL,
|
||||
SERVER_PORT INT NOT NULL,
|
||||
LAST_UPDATED_TIMESTAMP DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
CREATE TABLE IF NOT EXISTS SERVER_HEART_BEAT_EVENTS (
|
||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||
HOST_NAME VARCHAR(100) NOT NULL,
|
||||
MAC VARCHAR(100) NOT NULL,
|
||||
UUID VARCHAR(100) NOT NULL,
|
||||
SERVER_PORT INTEGER NOT NULL,
|
||||
LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
CREATE TABLE SERVER_HEART_BEAT_EVENTS (
|
||||
ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL,
|
||||
HOST_NAME VARCHAR(100) NOT NULL,
|
||||
MAC VARCHAR(100) NOT NULL,
|
||||
UUID VARCHAR(100) NOT NULL,
|
||||
SERVER_PORT INTEGER NOT NULL,
|
||||
LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
CREATE TABLE IF NOT EXISTS SERVER_HEART_BEAT_EVENTS (
|
||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||
HOST_NAME VARCHAR(100) NOT NULL,
|
||||
MAC VARCHAR(100) NOT NULL,
|
||||
UUID VARCHAR(100) NOT NULL,
|
||||
SERVER_PORT INTEGER NOT NULL,
|
||||
LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
instructions.configure = \
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.server.heart.beat_${feature.version}/datasources/,target:${installFolder}/../../../conf/datasources/,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.server.heart.beat_${feature.version}/conf/heart-beat-config.xml,target:${installFolder}/../../../conf/heart-beat-config.xml,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.server.heart.beat_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.server.heart.beat_${feature.version}/conf/heart-beat-config.xml,target:${installFolder}/../../conf/heart-beat-config.xml,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.server.heart.beat_${feature.version}/dbscripts/heart-beat/,target:${installFolder}/../../../dbscripts/heart-beat,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/database/);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.server.heart.beat_${feature.version}/database/,target:${installFolder}/../../../repository/database/,overwrite:true);\
|
||||
|
||||
instructions.unconfigure = \
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/datasources/heart-beat-datasources.xml);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/heart-beat);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/HeartBeat_DB.h2.db);\
|
||||
|
||||
Loading…
Reference in New Issue
Block a user