IBM Support

Anatomy of workspace/wstemp in WebSphere Application Server

Technical Blog Post


Abstract

Anatomy of workspace/wstemp in WebSphere Application Server

Body

 

What is Workspace:

Whenever a user logs into the administrative console, or uses wsadmin scripting to make a configuration change, the changes are stored in the workspace. When a user uses the ConfigService configuration service interface of the Java application programming interfaces (APIs), the user specifies a session object that is associated with the workspace in order to store the changes. Only when the user performs a save operation under the administrative console, wsadmin scripting, or the Java APIs are the changes propagated and merged with the master configuration repository.

 

For each administrative console user or each invocation of wsadmin scripting, the application server creates a separate workspace directory to store the intermediate changes until the changes are merged with the master configuration repository. Users of the Java APIs use different session objects to decide where the workspace directory resides. Both the administrative console and wsadmin scripting generate user IDs randomly. The user IDs are different from the user IDs that you use to log into the administrative console or wsadmin scripting. The Java APIs can either randomly generate the user ID or specify the user ID as an option when creating the session object.

 

Workspace keeps track of context and file states whenever a caller does an add / delete / extract / update using Workspace APIs.

 

Default wstemp directory location:  %user.install.root%\wstemp\
where %user.install.root% is %WAS_HOME%\profiles\<profile name>\


Changeable by setting following JVM custom property:

              UNIX platform:
                           -Dwebsphere.workspace.root=/temp
              Windows platform:
                           -Dwebsphere.workspace.root=c:\temp

 

Change the JVM custom property through the administrative console by setting the JVM property as a name-value pair on the Custom properties page.
For example,

    Under Console > Click System Administration > Deployment manager > Java and Process Management > Process definition > Java Virtual Machine > Custom properties.

 

Workspace directory location
%user.install.root%\wstemp\<user id>\workspace\
%websphere.workspace.root%\wstemp\<user id>\workspace\

 

 

Workspace generates the following files to keep track of the status of workspace, context and file:

WorkSpace State

  •     “.workspace_”<session id>

                     Under %user.install.root%\wstemp\<user id>\workspace directory to distinguish which session of the user works on the workspace.

                     This file contains a runtime call stack information from WorkSpaceManagerImpl.createWorkSpace(Properties)

Context State

  •     ".repositoryContext“

                     Under each <context type>\<context name> subdirectory of workspace, keep the status of the files being accessed.

 

File State

  •     <File Name>".copy": keep the digest of the file being extracted.
  •     <File Name>".current": keep the original copy of the file if merge is needed for this document. Only serverIndex.xml will be merged at this time.

 

 

Directory types generated under wstemp folder

  •     Script*: created by a wsadmin script;  
  •     anonymous*: created by client that pass a null workspace/session id.  
  •     -NNNNNNNNN: created by Admin Console  

 

 

It is the responsibility of the caller to remove the workspace session. It is better that the caller creates a session and then discards the session when finished. Each workspace is associated with a session object.


1. Session()
This one always creates a new unique session. The id of the session will be anonymous+current-time-in-millisecs. The following two lines will result in creation of a new unique workspace:

Session session = new Session();

configService.resolve(session, "Cell=");


So, every time a new session object is created this way and used, a new unique workspace directory will be created. Therefore, these workspaces should be removed by calling configService.discard(session) method or workspace.remove() method.


2. Session(id, resuse)
This one creates a new session based on the supplied id. If there is already a workspace created for that id, the same workspace will be used. However, it is not true if the reuse flag is set to false. If the reuse flag is set to false, a new session with id+current-time-in-millisecs is created.

  • The following two lines will result in creation of a new workspace if the corresponding workspace directory does not exist:

                    Session session = new Session("myWorkspace", true);
                    configService.resolve(session, "Cell=");  
    

                    The workspace must be removed by calling workspace.remove() or configservice.discard(session).  

  • The following two lines will result in creation of a new unique workspace 

                    Session session = new Session("myWorkspace", false);

                    configService.resolve(session, "Cell=");


Note: Every time a session object is created this way, it results in a new unique workspace. Therefore, all the workspaces created this way should be removed. If the caller code is not discarding the session it created, then the size of the wstemp folder will grow and eventually it can cause an OOM (out of memory) condition of dmgr or server depending on your setup.

 

One can turn on the following trace string either on deployment manager (or) on base application server depending on the type of setup to review the caller creating the workspace:

 

Current trace specification = *=info:com.ibm.ws.sm.workspace.impl.WorkSpaceManagerImpl=all

 

With above trace string is enabled one can see following logging in the trace.log file:

 

In the example, I used the case "anonymous*: created by client that pass a null workspace/session id"

 

[5/9/14 9:00:15:241 NZST] 00000001 WorkSpaceMana >  getWorkSpace, UserID: anonymous1399582815240, SessionID: null, create workspace if not found: true Entry
[5/9/14 9:00:15:241 NZST] 00000001 WorkSpaceMana 3   Call stack info of createWorkSpace(prop), workspace id anonymous1399582815240:        

<----- new workspace anonymous1399582815240 is created ----->

    com.ibm.ws.sm.workspace.impl.WorkSpaceManagerImpl.getCallStack(WorkSpaceManagerImpl.java:591)
    com.ibm.ws.sm.workspace.impl.WorkSpaceManagerImpl.createWorkSpace(WorkSpaceManagerImpl.java:148)
    com.ibm.ws.sm.workspace.impl.WorkSpaceManagerImpl.getWorkSpace(WorkSpaceManagerImpl.java:304)
    com.ibm.ws.sm.workspace.impl.WorkSpaceManagerImpl.getWorkSpace(WorkSpaceManagerImpl.java:241)
    com.ibm.ws.sm.workspace.impl.WorkSpaceManagerImpl.getWorkSpace(WorkSpaceManagerImpl.java:230)
    com.ibm.ws.management.configservice.WorkspaceHelper.getWorkspace(WorkspaceHelper.java:100)
    com.ibm.ws.management.configservice.WorkspaceHelper.getScopeContexts(WorkspaceHelper.java:344)
    com.ibm.ws.management.configservice.RootObjectDelegator.getAll(RootObjectDelegator.java:118)
    com.ibm.ws.management.configservice.ConfigServiceImpl.queryConfigObjects(ConfigServiceImpl.java:948)
    com.ibm.ws.management.configservice.ConfigServiceImpl.resolve(ConfigServiceImpl.java:1083)
    com.ibm.ws.management.configservice.ConfigServiceImpl.resolve(ConfigServiceImpl.java:1043)
    com.ibm.bpmcommon.upgrade.database.ValidateDatabaseVersion.getCluster(ValidateDatabaseVersion.java:226)
    com.ibm.bpmcommon.upgrade.database.ValidateDatabaseVersion.verifyStandardDB4ND(ValidateDatabaseVersion.java:199)
    com.ibm.bpmcommon.upgrade.database.ValidateDatabaseVersion.start(ValidateDatabaseVersion.java:120)
    com.ibm.ws.runtime.component.ContainerHelper.startComponents(ContainerHelper.java:539)
    com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:627)
    com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:618)
    com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:252)
    com.ibm.ws.runtime.component.ContainerHelper.startComponents(ContainerHelper.java:539)
    com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:627)
    com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:618)
    com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:523)
    com.ibm.ws.runtime.WsServerImpl.bootServerContainer(WsServerImpl.java:310)
    com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl.java:223)
    com.ibm.ws.runtime.WsServerImpl.main(WsServerImpl.java:686)
    com.ibm.ws.runtime.WsServer.main(WsServer.java:59)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    java.lang.reflect.Method.invoke(Method.java:611)
    com.ibm.wsspi.bootstrap.WSLauncher.launchMain(WSLauncher.java:234)
    com.ibm.wsspi.bootstrap.WSLauncher.main(WSLauncher.java:96)
    com.ibm.wsspi.bootstrap.WSLauncher.run(WSLauncher.java:77)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    java.lang.reflect.Method.invoke(Method.java:611)
    org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
    org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
    org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
    org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    java.lang.reflect.Method.invoke(Method.java:611)
    org.eclipse.core.launcher.Main.invokeFramework(Main.java:340)
    org.eclipse.core.launcher.Main.basicRun(Main.java:282)
    org.eclipse.core.launcher.Main.run(Main.java:981)
    com.ibm.wsspi.bootstrap.WSPreLauncher.launchEclipse(WSPreLauncher.java:380)
    com.ibm.wsspi.bootstrap.WSPreLauncher.main(WSPreLauncher.java:151)

[5/9/14 9:00:15:254 NZST] 00000001 WorkSpaceMana 3   Create workspace [WorkSpaceManagerImpl.createWorkSpace(prop)]...
     WorkspaceUserPath: /u01/app/dev/d4/bpm/node1/wstemp/anonymous1399582815240
     WorkspacePath ...: /u01/app/dev/d4/bpm/node1/wstemp/anonymous1399582815240/workspace
     repositoryAdapter: com.ibm.ws.sm.workspace.impl.WorkSpaceMasterRepositoryAdapter
[5/9/14 9:00:15:254 NZST] 00000001 WorkSpaceMana 3   getClassOfType, className: com.ibm.ws.sm.workspace.impl.WorkSpaceMasterRepositoryAdapter
[5/9/14 9:00:15:255 NZST] 00000001 WorkSpaceMana 3   profileKey
                                 <null>
[5/9/14 9:00:15:258 NZST] 00000001 WorkSpaceMana A   WKSP0500I: Workspace configuration consistency check is disabled.
[5/9/14 9:00:15:287 NZST] 00000001 WorkSpaceMana <  getWorkSpace, WS: com.ibm.ws.sm.workspace.impl.WorkSpaceImpl@e332d7a3 Exit
[5/9/14 9:00:15:299 NZST] 00000001 WorkSpaceMana >  getWorkSpace, UserID: anonymous1399582815240, SessionID: null, create workspace if not found: true Entry
[5/9/14 9:00:15:299 NZST] 00000001 WorkSpaceMana 3   The same sessionId share the same WorkSpace.
[5/9/14 9:00:15:300 NZST] 00000001 WorkSpaceMana <  getWorkSpace, WS: com.ibm.ws.sm.workspace.impl.WorkSpaceImpl@e332d7a3 Exit
[5/9/14 9:00:15:328 NZST] 00000001 WorkSpaceMana >  getWorkSpace, UserID: anonymous1399582815240, SessionID: null, create workspace if not found: true Entry
[5/9/14 9:00:15:328 NZST] 00000001 WorkSpaceMana 3   The same sessionId share the same WorkSpace.
[5/9/14 9:00:15:329 NZST] 00000001 WorkSpaceMana <  getWorkSpace, WS: com.ibm.ws.sm.workspace.impl.WorkSpaceImpl@e332d7a3 Exit
[5/9/14 9:00:15:330 NZST] 00000001 WorkSpaceMana >  getWorkSpace, UserID: anonymous1399582815240, SessionID: null, create workspace if not found: true Entry
[5/9/14 9:00:15:330 NZST] 00000001 WorkSpaceMana 3   The same sessionId share the same WorkSpace.
[5/9/14 9:00:15:330 NZST] 00000001 WorkSpaceMana <  getWorkSpace, WS: com.ibm.ws.sm.workspace.impl.WorkSpaceImpl@e332d7a3 Exit
[5/9/14 9:00:15:451 NZST] 00000001 WorkSpaceMana >  getWorkSpace, UserID: anonymous1399582815240, SessionID: null, create workspace if not found: true Entry
[5/9/14 9:00:15:458 NZST] 00000001 WorkSpaceMana 3   The same sessionId share the same WorkSpace.
[5/9/14 9:00:15:459 NZST] 00000001 WorkSpaceMana <  getWorkSpace, WS: com.ibm.ws.sm.workspace.impl.WorkSpaceImpl@e332d7a3 Exit
[5/9/14 9:00:15:472 NZST] 00000001 WorkSpaceMana 3   removeWorkSpace, UserID: anonymous1399582815240, SessionID: nullCall stack info of removeWorkSpace(string, string): 

<----- discard() method is being called properly hence anonymous1399582815240 is removed at the end of session ----->

   com.ibm.ws.sm.workspace.impl.WorkSpaceManagerImpl.getCallStack(WorkSpaceManagerImpl.java:591)
    com.ibm.ws.sm.workspace.impl.WorkSpaceManagerImpl.removeWorkSpace(WorkSpaceManagerImpl.java:452)
    com.ibm.ws.sm.workspace.impl.WorkSpaceManagerImpl.removeWorkSpace(WorkSpaceManagerImpl.java:446)
    com.ibm.ws.management.configservice.ConfigServiceImpl.discard(ConfigServiceImpl.java:789)
    com.ibm.bpmcommon.upgrade.database.ValidateDatabaseVersion.getCluster(ValidateDatabaseVersion.java:242)
    com.ibm.bpmcommon.upgrade.database.ValidateDatabaseVersion.verifyStandardDB4ND(ValidateDatabaseVersion.java:199)
    com.ibm.bpmcommon.upgrade.database.ValidateDatabaseVersion.start(ValidateDatabaseVersion.java:120)
    com.ibm.ws.runtime.component.ContainerHelper.startComponents(ContainerHelper.java:539)
    com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:627)
    com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:618)
    com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:252)
    com.ibm.ws.runtime.component.ContainerHelper.startComponents(ContainerHelper.java:539)
    com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:627)
    com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:618)
    com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:523)
    com.ibm.ws.runtime.WsServerImpl.bootServerContainer(WsServerImpl.java:310)
    com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl.java:223)
    com.ibm.ws.runtime.WsServerImpl.main(WsServerImpl.java:686)
    com.ibm.ws.runtime.WsServer.main(WsServer.java:59)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    java.lang.reflect.Method.invoke(Method.java:611)

 

If the discard() method was not being called then one would not see "WorkSpaceMana 3   removeWorkSpace," in the trace.log file when you look up on workspace UserID: anonymous1399582815240.

 

Note: If there is no discard() method being called, then workspace session does not get cleaned up. So if the code is making a lot of ConfigService API calls, then the /profile_home/wstemp directory keeps increasing which will eventually cause an OOM (Out Of Memory) condition on the JVM (deployment manager or appserver). As a work-around we can stop the JVM and clean up the contents of the "/profile_home/wstemp" directory. For a permanent solution, one should be looking at the code to make sure a discard method is being called to clear the workspace.

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"","label":""},"Component":"","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"","label":""}}]

UID

ibm11080939