Skip to content

Commit

Permalink
Refine logs and also inject request id in variablespace
Browse files Browse the repository at this point in the history
  • Loading branch information
zhicwu committed Jan 11, 2017
1 parent 1e38130 commit aecdf62
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.common.cache.CacheBuilder;
import org.pentaho.di.base.AbstractMeta;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.logging.LogChannel;
import org.pentaho.di.core.logging.LogChannelInterface;
import org.pentaho.di.core.parameters.NamedParams;
import org.pentaho.di.core.parameters.UnknownParamException;
Expand Down Expand Up @@ -132,24 +131,26 @@ public static Map<String, String> buildRequestParameters(String resourceName,
}
}

LogChannel.GENERAL.logError("=====> Request Parameters: " + map.toString());

return map;
}

public static void updateParametersAndCache(HttpServletRequest request, NamedParams params, String carteObjectId) {
public static void updateParametersAndCache(HttpServletRequest request,
NamedParams params,
VariableSpace vars,
String carteObjectId) {
String cacheId = request == null ? null : request.getHeader(KEY_ETL_CACHE_ID);
String requestId = request == null ? null : request.getHeader(KEY_ETL_REQUEST_ID);

LogChannel.GENERAL.logError(
"=====> cacheId=" + cacheId + ", requetId=" + requestId + ", carteId=" + carteObjectId);

if (!Strings.isNullOrEmpty(requestId)) {
try {
params.setParameterValue(KEY_ETL_REQUEST_ID, requestId);
} catch (UnknownParamException e) {
// this should not happen
}

if (vars != null) {
vars.setVariable(KEY_ETL_REQUEST_ID, requestId);
}
}

// update cache
Expand Down Expand Up @@ -182,6 +183,10 @@ public static Map.Entry<String, String> getCachedEntry(
WebResult webResult = WebResult.fromXMLString(reply);
if (webResult.getResult().equalsIgnoreCase(WebResult.STRING_OK)) {
identity = webResult.getId();
logBasic(server,
new StringBuilder()
.append("Found ").append(resourceName).append('=').append(identity)
.append(" on remote slave server").toString());
}
} catch (Exception e) {
// ignore as this is usually a network issue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro

if (trans != null) {
if (trans.isReadyToStart()) {
ServerCache.updateParametersAndCache(request, trans, id);
ServerCache.updateParametersAndCache(request, trans, trans, id);
startThreads(trans);

if (useXML) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
}
}

ServerCache.updateParametersAndCache(request, job, id);
ServerCache.updateParametersAndCache(request, job, job, id);
runJob(job);

String message = BaseMessages.getString(PKG, "StartJobServlet.Log.JobStarted", jobName);
Expand Down

0 comments on commit aecdf62

Please sign in to comment.