package org.jenkinsci.plugins.p4_client.client; import java.util.Properties; import com.perforce.p4java.PropertyDefs; import com.perforce.p4java.exception.ConnectionException; import com.perforce.p4java.impl.mapbased.rpc.RpcPropertyDefs; import com.perforce.p4java.server.IOptionsServer; import com.perforce.p4java.server.ServerFactory; /** * Connection Factory * * Provides concurrent connections to the Perforce Server * * @author pallen * */ public class ConnectionFactory { private static Identifier id = new Identifier(); private static ConnectionConfig currentConfig; private static IOptionsServer connection; /** * Returns existing connection * * @return */ public static IOptionsServer getConnection() { return connection; } /** * Provides a connection to the Perforce Server, initially client is * undefined. * * @param p4config * @return * @throws Exception * @throws ConnectionException * @throws Exception */ public static IOptionsServer getConnection(ConnectionConfig config) throws Exception { // Same config then return existing connection if (config != null && config.equals(currentConfig)) { if (connection.isConnected()) { return connection; } } // close old connection if (connection != null) { connection.disconnect(); } // set/reset server connection connection = createIOptionsServer(config); return connection; } /** * Creates a server connection * * @return * @throws Exception */ private static IOptionsServer createIOptionsServer(ConnectionConfig config) throws Exception { Properties props = System.getProperties(); // Identify ourselves in server log files. props.put(PropertyDefs.PROG_NAME_KEY, id.getProduct()); props.put(PropertyDefs.PROG_VERSION_KEY, id.getVersion()); // Set up socket pooling to use a single socket props.put(RpcPropertyDefs.RPC_SOCKET_POOL_SIZE_NICK, "1"); // Allow p4 admin commands. props.put(RpcPropertyDefs.RPC_RELAX_CMD_NAME_CHECKS_NICK, "true"); // disable timeout for slow servers / large db lock times props.put(RpcPropertyDefs.RPC_SOCKET_SO_TIMEOUT_NICK, "0"); // Get a server connection String serverUri = config.getServerUri(); IOptionsServer iserver; iserver = ServerFactory.getOptionsServer(serverUri, props); // Add trust for SSL connections if (config.isSsl()) { iserver.addTrust(config.getTrust()); } iserver.connect(); return iserver; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#7 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
#6 | 9431 | Paul Allen | Change to P4Java connection factory (trying to prevent connection reuse) | ||
#5 | 8815 | Paul Allen | P4D test harness. | ||
#4 | 8771 | Paul Allen |
Perforce Server 12.1 min check for: Build configuration and password/ticket credentials. Includes: - Added logging for Perforce connections (fine) and set connection pool to 2. - Add 'none' to empty charset list (connection bug?) - Supress P4Java errors for syncing ubinary, xtext, unicode |
||
#3 | 8762 | Paul Allen |
Console Ouptut logging for SCM build steps. - Removed SLF4J and used old style logger (matching Jenkins) - Set Client Host filed to null, Jenkins sometimes gives an IP address. - Test p4java setps in SCM tasks for success(true/false) |
||
#2 | 8660 | Paul Allen | Added P4TRUST for SSL connections in the Credentials plugin and ConnectionFactory. | ||
#1 | 8629 | Paul Allen |
Added p4java with connection/authorisation helper classes. Included SSL support and detection of Unicode servers. |