@Override public void OnExiting(Sender sender, SOAEventArg soaEventArg) { try { Thread.sleep(exitDelay); String onAzureEnv = System.getenv("CCP_OnAzure"); if (!Utility.isNullOrEmpty(onAzureEnv) && !onAzureEnv.equals("1") && Utility.isNullOrEmpty(logPath)) { String taskInfo = String.format( "%s.%s.%s", System.getenv(EnvVarNames.CCP_JOBID), System.getenv(EnvVarNames.CCP_TASKID), System.getenv(EnvVarNames.CCP_TASKINSTANCEID)); writeLog( logPath + "\\CCP_AITest_Trace_" + String.valueOf(jobid), refID, "[Request] %s%%%s%%Svchost called.", Utility.getCurrentTime(), taskInfo); } System.out.format("[Exit] %s: GracefulExitEvent called.%n", Utility.getCurrentTime()); info.setOnExitCalled(true); } catch (Exception e) { e.printStackTrace(); } }
/* * (non-Javadoc) * * @see org.tempuri.ITestService#echo(java.lang.Integer refID )* */ public org.datacontract.schemas._2004._07.services.ComputerInfo echo(java.lang.Integer refID) throws ITestServiceEchoAuthenticationFailureFaultFaultMessage, ITestServiceEchoRetryOperationErrorFaultFaultMessage { ServiceContext.Logger.traceEvent(Level.ALL, "Executing operation echo"); TestStruct ts = new TestStruct(); ts.setD(2d); ts.setF(3f); ts.setI64(4l); ts.setI321(1); ts.setI322(2); ts.setS(svcObjFact.createTestStructS("")); ComputerInfo info = new ComputerInfo(); info.setRefID(refID); String machineName; try { machineName = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { machineName = ""; } info.setName(svcObjFact.createComputerInfoName(machineName)); info.setJobID(jobid); info.setTaskID(taskid); info.setScheduler(svcObjFact.createComputerInfoScheduler(scheduler)); try { info.setCallIn(Utility.getXMLCurrentTime()); } catch (DatatypeConfigurationException e1) { e1.printStackTrace(); System.exit(1); } info.setTs(ts); String username = System.getProperty("user.name"); info.setRunAsUser(svcObjFact.createComputerInfoRunAsUser(username)); info.setOnExitCalled(false); Map<String, String> envMap = System.getenv(); List<KeyValueOfstringstring> envList = new ArrayList<KeyValueOfstringstring>(); for (String envName : envMap.keySet()) { KeyValueOfstringstring entry = new KeyValueOfstringstring(); entry.setKey(envName); entry.setValue(envMap.get(envName)); envList.add(entry); if (envName.compareToIgnoreCase(EnvVarNames.NON_TERMINATING_ERROR_RETRY_COUNT) == 0) { if (NonTerminatingErrorRetryCount < Integer.parseInt(entry.getValue())) { NonTerminatingErrorRetryCount++; System.out.format( "Throw NonTerminatingErrorRetryCount times: %d%n", NonTerminatingErrorRetryCount); throw Utility.BuildRetryOperationError( "test", String.valueOf(NonTerminatingErrorRetryCount)); } } } String WriteFileTest = System.getenv(EnvVarNames.WRITE_FAIL_TEST); if (!Utility.isNullOrEmpty(WriteFileTest)) { try { for (String file : WriteFileTest.split(";")) { System.out.format("Begin to write file %s%n", file); FileWriter writer = new FileWriter(new File(file), true); writer.close(); } for (String file : WriteFileTest.split(";")) { System.out.format("Begin to delete file %s%n", file); File f = new File(file); f.delete(); } } catch (Exception e) { e.printStackTrace(); throw Utility.BuildRetryOperationError(e.toString()); } } System.out.format("Called %d%n", refID); return info; }