Skip to content
Snippets Groups Projects
Commit 6044fa7b authored by Yann Huriez's avatar Yann Huriez
Browse files

release_2_3_10

parent 64350400
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,9 @@
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" including="**/*.java" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
......@@ -20,8 +20,14 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.devzuz.q.maven.jdt.core.mavenNature</nature>
......
......@@ -9,7 +9,7 @@
</parent>
<groupId>fr.soleil.deviceservers</groupId>
<artifactId>hdbtdbArchivingServers</artifactId>
<version>2.3.10-SNAPSHOT</version>
<version>2.3.10</version>
<name>hdbtdbArchivingServers</name>
<developers>
<developer>
......
......@@ -303,6 +303,12 @@ public final class DbProxy {
periods.put(completeName, period);
}
public void closeConnection() {
if (manager != null) {
manager.closeConnection();
}
}
/*
* (non-Javadoc)
*
......
......@@ -425,6 +425,8 @@ public class HdbArchiver extends DeviceImpl implements TangoConst {
protected int state;
private DbProxy dbProxy;
private boolean databaseConnectionFault = false;
private InitDeviceTask initDeviceTast;
// --------- Start of attributes data members ----------
......@@ -454,6 +456,7 @@ public class HdbArchiver extends DeviceImpl implements TangoConst {
* <b>Default value : </b> Class Value
*/
private String dbUser;
/**
* Password used to connect the database HDB. <br>
* <b>Default value : </b> Class Value
......@@ -608,6 +611,11 @@ public class HdbArchiver extends DeviceImpl implements TangoConst {
get_logger().info("HdbArchiver() create " + device_name);
if (databaseConnectionFault) {
get_logger().error(
"The connection with the database hasn't been made previously, "
+ "so you'll need to restart the device to make the connection work correctly.");
} else {
// Initialise variables to default values
// -------------------------------------------
get_device_property();
......@@ -624,6 +632,7 @@ public class HdbArchiver extends DeviceImpl implements TangoConst {
attr_scalar_charge_read = 0;
koAttributes.clear();
okAttributes.clear();
logger.info("DbHost = " + dbHost);
logger.info("DbName = " + dbName);
logger.info("dbUser = " + dbUser);
......@@ -636,16 +645,27 @@ public class HdbArchiver extends DeviceImpl implements TangoConst {
logger.info("hasDiary = " + hasDiary);
logger.info("diaryLogLevel = " + diaryLogLevel);
connect_database();
}
logger.debug("init done");
}
private void connect_database() {
try {
dbProxy = new DbProxy(dbHost, dbName, dbSchema, dbUser, dbPassword, RacConnection, logger);
// setControlMode(safetyPeriod);
// start archiving in a thread
Executors.newSingleThreadExecutor().submit(new InitDeviceTask());
if (initDeviceTast == null) {
initDeviceTast = new InitDeviceTask();
}
Executors.newSingleThreadExecutor().submit(initDeviceTast);
} catch (final ArchivingException e) {
TangoStateUtils.setFault(this, "Historical database connection failed: " + e);
logger.error("ERROR : Database unconnected !!", e);
databaseConnectionFault = true;
}
logger.debug("init done");
}
/**
......@@ -676,6 +696,7 @@ public class HdbArchiver extends DeviceImpl implements TangoConst {
try {
myCurrentTasks = dbProxy.getArchiverCurrentTasks(device_name);
} catch (final ArchivingException e) {
e.printStackTrace();
logger.debug("cannot getArchiverCurrentTasks " + e);
TangoStateUtils.setFault(HdbArchiver.this, e.getMessage());
}
......@@ -974,7 +995,23 @@ public class HdbArchiver extends DeviceImpl implements TangoConst {
// =========================================================
@Override
public void always_executed_hook() throws DevFailed {
// Uncomment to allow the device to trying reconnection when a commend
// is triggered. May not work with Oracle jdbc drivers.
// System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> always executed hook");
// System.out.println("======================================== isDbProxy null : "
// + (dbProxy == null));
// if (dbProxy != null) {
// System.out.println("======================================== isDbConnected : "
// + dbProxy.isDbConnected());
// }
//
// if (dbProxy == null || (dbProxy != null && !dbProxy.isDbConnected()))
// {
// logger.info("Trying to reconnect database...");
// delete_device();
// init_device();
// }
}
// ===================================================================
......@@ -1796,7 +1833,11 @@ public class HdbArchiver extends DeviceImpl implements TangoConst {
@Override
public void delete_device() throws DevFailed {
Except.throw_exception("not supported", "please, restart device", "delete_device");
// if (dbProxy != null && dbProxy.isDbConnected()) {
// dbProxy.closeConnection();
// // Except.throw_exception("not supported", "please, restart device",
// // "delete_device");
// }
}
}
......
......@@ -576,6 +576,8 @@ public class TdbArchiver extends DeviceImpl implements TangoConst {
private String dbSchema;
private Logger logger;
private boolean databaseConnectionFault = false;
// --------------------------------------
// =========================================================
......@@ -623,6 +625,13 @@ public class TdbArchiver extends DeviceImpl implements TangoConst {
// =========================================================
@Override
public void init_device() throws DevFailed {
System.out.println("-------------------------------------- init_device in");
if (databaseConnectionFault) {
get_logger().error(
"The connection with the database hasn't been made previously, "
+ "so you'll need to restart the device to make the connection work correctly.");
} else {
get_logger().info("TdbArchiver() create " + device_name);
get_device_property();
......@@ -661,7 +670,11 @@ public class TdbArchiver extends DeviceImpl implements TangoConst {
} catch (final ArchivingException e) {
TangoStateUtils.setFault(this, "Historical database connection failed: " + e);
logger.error("ERROR : Database unconnected !!");
databaseConnectionFault = true;
}
}
System.out.println("------------------------------------- init_device out");
}
......@@ -1481,7 +1494,8 @@ public class TdbArchiver extends DeviceImpl implements TangoConst {
@Override
public void delete_device() throws DevFailed {
Except.throw_exception("not supported", "please, restart device", "delete_device");
// Except.throw_exception("not supported", "please, restart device",
// "delete_device");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment