要求度量延伸

在要求度量流程中,特定應用程式可能會需要其他檢測點。 例如,您可能會想要瞭解某獨特後端系統的回應時間,如下列呼叫曲線所示:

HTTP request /trade/scenario             ------------------------------> 172 ms
Servlet/trade/scenario          --------------------------------> 130 ms
Servlet/call to unique back-end system -------------------------->38 ms

當追蹤每個要求在系統中的流程時,要求度量會使用「記號」或「相關性因子」。 如果要利用這項檢測來建立上述呼叫曲線,您必須插入這個要求流程,並發出適當的「應用程式回應測量 (ARM)」API,使 ARM 代理程式能夠收集資料,且 ARM 供應商能夠建立呼叫曲線。

要求度量會顯現「相關性服務 API」,供您插入要求流程。 下列範例是典型的流程之一,後面可能會接著一個要插入要求度量流程的受檢測應用程式:
  1. 建立一個新的 ArmTransaction 物件,由它執行各種檢測呼叫,例如,start 或 stop。在插入要求度量流程之前,「相關性服務 ARM」封套 (PmiRmArmTx) 會封裝這個物件。
  2. 將適當的 ArmCorrelator 物件移入 ArmTransaction 物件中。這個物件會封裝實際的 ARM 相關性因子位元組。
  3. 執行 ArmTransaction 物件的 start 方法,將所檢測方法的開頭標示出來。
  4. 利用 PmiRmArmTxFactory 類別的 static 方法來建立 PmiRmArmTx 物件的實例,並將上述 ArmTransaction 物件移入 PmiRmArmTx 物件中。
  5. 利用 PmiRmArmStack 類別上所顯現的方法,將上述 PmiRmArmTx 物件推送到「相關性服務」堆疊,以便將它傳給「相關性服務」。
  6. 執行必須由所檢測方法來完成的作業。「相關性服務」會依需要來處理 ArmTransaction 物件流程,最終會形成交易次數的呼叫曲線視圖。
  7. 在所檢測方法結束時,請利用 PmiRmArmStack 類別上所顯現的方法,從「相關性服務」存取 PmiRmArmTx 物件、存取 ArmTransaction 物件,然後執行 stop 來指示交易結束。

在 Servlet 檢測中搭配相關性服務來使用 ARM API 時,請參考這個資訊。

arm40 二進位檔應該依照實作提供者所提供的安裝指示來安裝。 這個作業完成之後,請重新啟動伺服器。 這會導致在 SystemOut.log 檔中產生追蹤記錄,指示已建立適當 ARM 實作的實例。 下列範例說明在 Servlet 檢測中,結合相關性服務來使用 ARM API 的典型工作流程之一:

public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException {

PmiRmArmTx artrax =
// The factory detects the currently active ARM implementation (specified by user through
// admin console) and instantiates an appropriate ARM wrapper object

    PmiRmArmTxFactory.createPmiRmArmTx();
ArmTransaction at = newArmTx();
if (null == at)
            out.println("Got a null ArmTransaction");
ArmCorrelator arc = newArmCorr();
at.start(arc);
try {
	artrax.setArmTransaction(at);
	PmiRmArmStack.pushTransaction(artrax);
} catch (Exception e) {
	System.out.println("Caught 1 exception" + e);
}

PmiRmArmTx atxwrp = PmiRmArmStack.peekTransaction();

if (atxwrp == null)
	out.println("Armtransaction is null");

//getArmType
try {
	out.println("ARMTYPE is"+ PmiRmArmTx.getARMType());
} catch (Exception e) {
	out.println(e);
}
//getting correlator bytes
try {
	if (null == atxwrp.getCorrelatorBytes())
		out.println("Got a null Correlator");
} catch (Exception e) {
	out.println(e);
}

//blocked/unblocked
long blkid = 0;
try {
	out.println(blkid = atxwrp.blocked());
} catch (Exception e) {
	out.println(e);
}

try {
	out.println(atxwrp.unblocked(blkid));
} catch (Exception e) {
	out.println(e);
}
try {
	atxwrp = PmiRmArmStack.popTransaction();
	ArmTransaction art = (ArmTransaction) atxwrp.getArmTransaction();
	art.stop(ArmConstants.STATUS_GOOD);
} catch (Exception e) {
	out.println(e);
}

}



private ArmTransaction newArmTx() {

	ArmTransactionFactory txFactory = null;
try {
	String sWasName = "WebSphere";
	String appName = "t23xpimage/t23xpimage/server1";
	String sCellName = appName.substring(0, appName.indexOf("/"));
	String sNodeInstance =
			appName.substring(appName.indexOf("/") + 1, appName.length());
	sNodeInstance = sNodeInstance.replace('/', '.');
	txFactory =	(ArmTransactionFactory)
	newObjectInstance("org.opengroup.arm40.sdk.ArmTransactionFactoryImpl");
	ArmApplication app = null; // 149297
	ArmApplicationDefinition appDef = null; //LIDB3207
	appDef =				txFactory.newArmApplicationDefinition(sWasName, null, null);
	app = txFactory.newArmApplication(appDef, sCellName, sNodeInstance, null);

	String[] idnames = { "request_type" };
	String[] idvalues = { "URI" };
	String[] ctxnames = { "URI" };
	ArmIdentityPropertiesTransaction props =
			txFactory.newArmIdentityPropertiesTransaction(
					idnames,
					idvalues,
					ctxnames,
					null);
	ArmTransactionDefinition atd =
				txFactory.newArmTransactionDefinition(
					appDef,
					"URI",
					props,
					(ArmID) null);
	ArmTransaction at = txFactory.newArmTransaction(app, atd);
	return at;
} catch (Exception e) {
	System.out.println(e);
	return null;
}

}

private ArmCorrelator newArmCorr() {

	ArmTransactionFactory txFactory = null;
try {
	String sWasName = "WebSphere";
	String appName = "t23xpimage/t23xpimage/server1";
	txFactory =
	(ArmTransactionFactory) newObjectInstance("org.opengroup.arm40.sdk.ArmTransactionFactoryImpl");

	ArmCorrelator arc =txFactory.newArmCorrelator(
					PmiRmArmStack.peekTransaction().getCorrelatorBytes());
	return arc;
} catch (Exception e) {
	System.out.println(e);
	return null;
}

}
註: 這個主題參照一或多個應用程式伺服器日誌檔。 此外,在分散式和 IBM® i 系統上,另外也建議您可以配置伺服器來使用「高效能可延伸記載 (HPEL)」日誌和追蹤基礎架構,而不使用 SystemOut.logSystemErr.log, trace.logactivity.log 檔案。HPEL 與原生 z/OS® 記載機能也可以一起使用。如果您使用 HPEL,則可以從伺服器設定檔 bin 目錄,利用 LogViewer 指令行工具來存取您所有的日誌和追蹤資訊。請參閱有關利用 HPEL 疑難排解應用程式的資訊,以取得更多使用 HPEL 的相關資訊。

使用 PmiRmArmStack 有若干可能的實務。 這個範例顯示的實務是:程式碼存取堆疊上現有的 PmiRmArmTx、擷取相關性因子,然後呼叫 blocked 和 unblocked。 這是按照不支援的通訊協定來傳送相關性因子的典型實務。 在這個實務中,Arm 交易已在堆疊上。

1			PmiRmArmTx artrax =
2				PmiRmArmStack.peekTransaction();
3			if( artrax != null )
4	                        {
5	                                    try
6	                                    {
7				    byte[] cbytes = artrax.getCorrelatorBytes();
8	                                        stuffBytesIntoOutboundMessage( msg, cbytes);
9	                                         long blockedId = 0;
10	                                        try
11	                                        {
12	                                           blockedId = artrax.blocked();
13	                                         }
14	                                         catch( NoSuchMethodException nsme )
15	                                         {
16	                                             // must not be running ARM4 or eWLM
17	                                         }
18	                                           sendMsg( msg );
19	                                        try
20	                                        {
21	                                           artrax.blocked( blockedId );
22	                                         }
23	                                         catch( NoSuchMethodException nsme )
24	                                         {
25	                                             // must not be running ARM4 or eWLM
26	                                         }
27	
28	                                     }
29	                                     catch( Exception e )
30	                                     {
31	                                        report a problem;
32	                                     }
33			}
 

指出主題類型的圖示 概念主題



時間戳記圖示 前次更新: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=cprf_corrservinterface
檔名:cprf_corrservinterface.html