-
Type:
Bug
-
Resolution: Won't Fix
-
Priority:
Major
-
Component/s: p4-plugin
-
None
-
Environment:Platform: All, OS: All
Appended you find a patch with 3 changes I have made to class
hudson.plugins.perforce.PerforceSCM in the perforce plugin.
- a javadoc typo
- a fix for string comparison with !=
- a fix which caused very heavy perforce server load
I must admit I'm not sure if the last fix is ok. At least it works for us.
The heavy perforce server load was caused by polling changes against a
non-existing master p4 client. If you call 'p4 client client-name' with an
non-existing client, perforce will answer with a client view which shows the
complete perforce repository. Polling changes against this view causes heavy
server load. When Hudson builds a project on a slave for the first time, it
creates the slave p4 client, but not the master p4 client. However the changes
are polled with the master p4 client. The patch creates the master p4 client, if
it does not exist.
Index: src/main/java/hudson/plugins/perforce/PerforceSCM.java
===================================================================
— src/main/java/hudson/plugins/perforce/PerforceSCM.java (revision 17570)
+++ src/main/java/hudson/plugins/perforce/PerforceSCM.java Tue Apr 28 18:15:23
CEST 2009
@@ -83,7 +83,7 @@
boolean updateView = true;
/**
- * If false we add the slave hostname to then end of the client name when
+ * If false we add the slave hostname to the end of the client name when
- running on a slave
*/
boolean dontRenameClient = false;
@@ -280,7 +280,7 @@
String nodeSuffix = "";
if ( !dontRenameClient &&
build.getBuiltOnStr() != null &&
- build.getBuiltOnStr() != "") {
+ build.getBuiltOnStr().length() > 0) {
//use the 1st part of the hostname as the node suffix
String host = workspace.act(new GetHostname());
@@ -323,7 +323,26 @@
if (dontRenameClient)
+
+ // Create a master p4 client if it does not exist and
we are on a slave.
+ // A master p4 client is required for polling changes later. If missing
+ // the 'p4 client' command returns a view for the whole
perforce repository,
+ // which causes heavy perforce server load when
requesting changes.
+ if(nodeSuffix.length() > 0 && (updateView || creatingNewWorkspace))Unknown macro: {+ Workspace p4MasterWorkspace = getDepot(launcher,workspace).getWorkspaces().getWorkspace(p4Client);+ boolean createMasterWorkspace = p4MasterWorkspace.getAccess() == null ||p4MasterWorkspace.getAccess().length() == 0;+ if (createMasterWorkspace) { + p4MasterWorkspace.setName(p4Client); // necessary ? + String view = projectPath + " //" + p4MasterWorkspace.getName() + "/..."; + log.println("Creating Master P4 Client: view=" + view); + p4MasterWorkspace.clearViews(); + p4MasterWorkspace.addView(view); + p4MasterWorkspace.setHost(""); + // create the p4 client + depot.getWorkspaces().saveWorkspace(p4MasterWorkspace); + }+ }+
//save the client for use when sync'ing in a few...
depot.getWorkspaces().saveWorkspace(p4workspace);