1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
package ppaceMaker;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import utilities.TraitementLong;
import utilities.Utils;
import com.sciforma.psnext.api.PSException;
public class ConnectionDiagnosis_V6 {
static final long start = System.currentTimeMillis();
static long now = start;
final boolean OK = true;
private static int TIME_OUT = 10;
private static final Logger logger = Logger.getLogger("PACEMAKER");
static boolean timeOut = false;
static boolean success = false;
private synchronized static void lanchtest() throws InterruptedException,
PSException {
TraitementLong mytest = new TraitementLong(true, true);
mytest.closeSession();
}
static Thread tTraitementLong = new Thread(new Runnable() {
public void run() {
// le code qui te prend du temps
try {
lanchtest();
success = true;
} catch (InterruptedException Ie) {
System.err.println("LA0");
Ie.printStackTrace(); // jamais
} catch (PSException pse) {
System.err.println("LA1");
pse.printStackTrace(); // interruption
} catch (Exception e) {
System.err.println("LA2");
e.printStackTrace(); // eventuelle
}
}
});
public static void checkJobDate() {
}
public static void main(java.lang.String[] args) {
PropertyConfigurator.configure(ConnectionDiagnosis.class
.getClassLoader().getResource("conf/log4j.properties"));
logger.info("Starting Diagnosis");
tTraitementLong.start();
try {
tTraitementLong.join(TIME_OUT * 1000);
if (tTraitementLong.isAlive()) {
// Fin Echec
tTraitementLong.interrupt();
//tTraitementLong.stop();
System.err.println("Echec TimeOut");
} else {
// Fin Succes
if (success) {
System.out.println("Reussite");
}
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.err.println("LA3");
} catch (Exception ex) {
ex.printStackTrace();
System.err.println("LA4");
}
System.out.println("HERE");
logger.info("Ending Diagnosis");
Utils.timeIt(start);
}
} |
Partager