From 0889a66f9c1e8a725c63362ea5ddbbfc1f9d70cb Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 24 Jun 2016 16:21:25 +1000 Subject: [PATCH] Issue #663 --- .../jetty-gcloud-session-manager/pom.xml | 2 +- .../config/etc/sessions/gcloud/embedded.xml | 13 - .../main/config/etc/sessions/gcloud/local.xml | 14 - .../config/etc/sessions/gcloud/remote.xml | 19 - .../etc/sessions/gcloud/session-store.xml | 1 - .../config/modules/session-store-gcloud.mod | 76 ++-- .../gcloud/session/GCloudConfiguration.java | 197 ---------- .../session/GCloudSessionDataStore.java | 106 +++--- .../GCloudSessionDataStoreFactory.java | 11 - .../gcloud/session/GCloudSessionTester.java | 7 +- jetty-gcloud/pom.xml | 2 +- .../ClientCrossContextSessionTest.java | 2 +- .../gcloud/session/ForwardedSessionTest.java | 2 +- .../session/GCloudSessionTestSupport.java | 342 +++--------------- .../gcloud/session/GCloudTestServer.java | 6 +- .../gcloud/session/ImmediateSaveTest.java | 2 +- .../gcloud/session/ImmortalSessionTest.java | 2 +- .../session/InvalidationSessionTest.java | 2 +- .../gcloud/session/LastAccessTimeTest.java | 2 +- .../session/LocalSessionScavengingTest.java | 2 +- .../jetty/gcloud/session/NewSessionTest.java | 2 +- .../gcloud/session/OrphanedSessionTest.java | 2 +- .../session/ReentrantRequestSessionTest.java | 2 +- .../gcloud/session/RemoveSessionTest.java | 2 +- .../gcloud/session/SameNodeLoadTest.java | 2 +- .../ServerCrossContextSessionTest.java | 2 +- .../gcloud/session/SessionExpiryTest.java | 2 +- .../SessionInvalidateAndCreateTest.java | 2 +- .../gcloud/session/SessionMigrationTest.java | 2 +- .../gcloud/session/SessionRenewTest.java | 2 +- .../session/SessionValueSavingTest.java | 2 +- ...StopSessionManagerPreserveSessionTest.java | 2 +- .../session/InfinispanTestSessionServer.java | 2 +- .../jetty/server/session/JdbcTestServer.java | 4 +- 34 files changed, 159 insertions(+), 681 deletions(-) delete mode 100644 jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/embedded.xml delete mode 100644 jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/local.xml delete mode 100644 jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/remote.xml delete mode 100644 jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudConfiguration.java diff --git a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml index 3953a5a9c3f..c75e1f1614a 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml +++ b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml @@ -17,7 +17,7 @@ ${project.version} - com.google.gcloud + com.google.cloud gcloud-java-datastore ${gcloud.version} diff --git a/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/embedded.xml b/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/embedded.xml deleted file mode 100644 index eb698882a1d..00000000000 --- a/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/embedded.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/local.xml b/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/local.xml deleted file mode 100644 index 9a355e2391f..00000000000 --- a/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/local.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/remote.xml b/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/remote.xml deleted file mode 100644 index 8e4db212ca8..00000000000 --- a/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/remote.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/session-store.xml b/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/session-store.xml index b36ecda743d..003d0e24f9e 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/session-store.xml +++ b/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/etc/sessions/gcloud/session-store.xml @@ -10,7 +10,6 @@ - diff --git a/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/modules/session-store-gcloud.mod b/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/modules/session-store-gcloud.mod index 96ac8c6f13f..f9f9b443018 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/modules/session-store-gcloud.mod +++ b/jetty-gcloud/jetty-gcloud-session-manager/src/main/config/modules/session-store-gcloud.mod @@ -8,41 +8,43 @@ session-store annotations webapp sessions -sessions/gcloud/${type} jcl-api jcl-impl [files] -maven://com.google.gcloud/gcloud-java-datastore/0.0.7|lib/gcloud/gcloud-java-datastore-0.0.7.jar -maven://com.google.gcloud/gcloud-java-core/0.0.7|lib/gcloud/gcloud-java-core-0.0.7.jar -maven://com.google.auth/google-auth-library-credentials/0.1.0|lib/gcloud/google-auth-library-credentials-0.1.0.jar -maven://com.google.auth/google-auth-library-oauth2-http/0.1.0|lib/gcloud/google-auth-library-oauth2-http-0.1.0.jar +maven://com.google.cloud/gcloud-java-datastore/0.2.3|lib/gcloud/gcloud-java-datastore-0.2.3.jar +maven://com.google.cloud/gcloud-java-core/0.2.3|lib/gcloud/gcloud-java-core-0.2.3.jar +maven://com.google.auth/google-auth-library-credentials/0.3.1|lib/gcloud/google-auth-library-credentials-0.3.1.jar +maven://com.google.auth/google-auth-library-oauth2-http/0.3.1|lib/gcloud/google-auth-library-oauth2-http-0.3.1.jar maven://com.google.http-client/google-http-client-jackson2/1.19.0|lib/gcloud/google-http-client-jackson2-1.19.0.jar maven://com.fasterxml.jackson.core/jackson-core/2.1.3|lib/gcloud/jackson-core-2.1.3.jar -maven://com.google.http-client/google-http-client/1.20.0|lib/gcloud/google-http-client-1.20.0.jar +maven://com.google.http-client/google-http-client/1.21.0|lib/gcloud/google-http-client-1.21.0.jar maven://com.google.code.findbugs/jsr305/1.3.9|lib/gcloud/jsr305-1.3.9.jar maven://org.apache.httpcomponents/httpclient/4.0.1|lib/gcloud/httpclient-4.0.1.jar maven://org.apache.httpcomponents/httpcore/4.0.1|lib/gcloud/httpcore-4.0.1.jar maven://commons-codec/commons-codec/1.3|lib/gcloud/commons-codec-1.3.jar -maven://com.google.oauth-client/google-oauth-client/1.20.0|lib/gcloud//google-oauth-client-1.20.0.jar -maven://com.google.guava/guava/18.0|lib/gcloud/guava-18.0.jar -maven://com.google.api-client/google-api-client-appengine/1.20.0|lib/gcloud/google-api-client-appengine-1.20.0.jar -maven://com.google.oauth-client/google-oauth-client-appengine/1.20.0|lib/gcloud/google-oauth-client-appengine-1.20.0.jar -maven://com.google.oauth-client/google-oauth-client-servlet/1.20.0|lib/gcloud/google-oauth-client-servlet-1.20.0.jar -maven://com.google.http-client/google-http-client-jdo/1.20.0|lib/gcloud/google-http-client-jdo-1.20.0.jar -maven://com.google.api-client/google-api-client-servlet/1.20.0|lib/gcloud/google-api-client-servlet-1.20.0.jar +maven://com.google.oauth-client/google-oauth-client/1.21.0|lib/gcloud/google-oauth-client-1.21.0.jar +maven://com.google.guava/guava/19.0|lib/gcloud/guava-19.0.jar +maven://com.google.api-client/google-api-client-appengine/1.21.0|lib/gcloud/google-api-client-appengine-1.21.0.jar +maven://com.google.oauth-client/google-oauth-client-appengine/1.21.0|lib/gcloud/google-oauth-client-appengine-1.21.0.jar +maven://com.google.oauth-client/google-oauth-client-servlet/1.21.0|lib/gcloud/google-oauth-client-servlet-1.21.0.jar +maven://com.google.http-client/google-http-client-jdo/1.21.0|lib/gcloud/google-http-client-jdo-1.21.0.jar +maven://com.google.api-client/google-api-client-servlet/1.21.0|lib/gcloud/google-api-client-servlet-1.21.0.jar maven://javax.jdo/jdo2-api/2.3-eb|lib/gcloud/jdo2-api-2.3-eb.jar maven://javax.transaction/transaction-api/1.1|lib/gcloud/transaction-api-1.1.jar -maven://com.google.http-client/google-http-client-appengine/1.20.0|lib/gcloud/google-http-client-appengine-1.20.0.jar -maven://com.google.http-client/google-http-client-jackson/1.20.0|lib/gcloud/google-http-client-jackson-1.20.0.jar +maven://com.google.http-client/google-http-client-appengine/1.21.0|lib/gcloud/google-http-client-appengine-1.21.0.jar +maven://com.google.http-client/google-http-client-jackson/1.21.0|lib/gcloud/google-http-client-jackson-1.21.0.jar maven://org.codehaus.jackson/jackson-core-asl/1.9.11|lib/gcloud/jackson-core-asl-1.9.11.jar -maven://joda-time/joda-time/2.8.2|lib/gcloud/joda-time-2.8.2.jar -maven://org.json/json/20090211|lib/gcloud/json-20090211.jar -maven://com.google.apis/google-api-services-datastore-protobuf/v1beta2-rev1-2.1.2|lib/gcloud/google-api-services-datastore-protobuf-v1beta2-rev1-2.1.2.jar -maven://com.google.protobuf/protobuf-java/2.5.0|lib/gcloud/protobuf-java-2.5.0.jar -maven://com.google.http-client/google-http-client-protobuf/1.15.0-rc|lib/gcloud/google-http-client-protobuf-1.15.0-rc.jar -maven://com.google.api-client/google-api-client/1.15.0-rc|lib/gcloud/google-api-client-1.15.0-rc.jar -maven://com.google.apis/google-api-services-datastore/v1beta2-rev23-1.19.0|lib/gcloud/google-api-services-datastore-v1beta2-rev23-1.19.0.jar +maven://joda-time/joda-time/2.9.2|lib/gcloud/joda-time-2.9.2.jar +maven://org.json/json/20151123|lib/gcloud/json-20151123.jar +maven://com.google.cloud.datastore/datastore-v1beta3-protos/1.0.0-beta|lib/gcloud/datastore-v1beta3-protos-1.0.0-beta.jar +maven://com.google.protobuf/protobuf-java/3.0.0-beta-1|lib/gcloud/protobuf-java-3.0.0-beta-1.jar +maven://com.google.cloud.datastore/datastore-v1beta3-proto-client/1.0.0-beta.2|lib/gcloud/datastore-v1beta3-proto-client-1.0.0-beta.2.jar +maven://com.google.http-client/google-http-client-protobuf/1.20.0|lib/gcloud/google-http-client-protobuf-1.20.0.jar +maven://com.google.api-client/google-api-client/1.20.0|lib/gcloud/google-api-client-1.20.0.jar +maven://com.google.guava/guava-jdk5/13.0|lib/gcloud/guava-jdk5-13.0.jar + + [lib] lib/jetty-gcloud-session-manager-${jetty.version}.jar @@ -56,39 +58,9 @@ GCloudDatastore is an open source project hosted on Github and released under th https://github.com/GoogleCloudPlatform/gcloud-java http://www.apache.org/licenses/LICENSE-2.0.html -[ini] -type=remote - [ini-template] ## GCloudDatastore Session config #jetty.gcloudSession.maxRetries= #jetty.gcloudSession.backoffMs= - -## Remote datastore -type=remote -## The gcloud projectId -## Set this property to connect to remote gcloud datastore. -## Or, set the DATASTORE_DATASET System property/env variable instead. -#jetty.gcloudSession.projectId= - -## The p12 file associated with the project. -## Set this property only when connecting to remote gcloud datastore -#jetty.gcloudSession.p12File= - -## The serviceAccount for the Datastore. -## Set this property only when connecting to remote gcloud datastore -#jetty.gcloudSession.serviceAccount= - -## The password (can be obfuscated). -## Set this property only when connecting to remote gcloud datastore -#jetty.gcloudSession.password= - - -## Local datastore -#type=local - - -## Embedded datastore -#type=embedded diff --git a/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudConfiguration.java b/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudConfiguration.java deleted file mode 100644 index 0db8805b9e1..00000000000 --- a/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudConfiguration.java +++ /dev/null @@ -1,197 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd. -// ------------------------------------------------------------------------ -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// and Apache License v2.0 which accompanies this distribution. -// -// The Eclipse Public License is available at -// http://www.eclipse.org/legal/epl-v10.html -// -// The Apache License v2.0 is available at -// http://www.opensource.org/licenses/apache2.0.php -// -// You may elect to redistribute this code under either of these licenses. -// ======================================================================== -// - - -package org.eclipse.jetty.gcloud.session; - -import com.google.gcloud.AuthCredentials; -import com.google.gcloud.datastore.DatastoreOptions; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.security.KeyStore; -import java.security.PrivateKey; -import java.util.Properties; - -import org.eclipse.jetty.util.security.Password; - - - -/** - * GCloudConfiguration - * - * - */ -public class GCloudConfiguration -{ - public static final String PROJECT_ID = "projectId"; - public static final String P12 = "p12"; - public static final String PASSWORD = "password"; - public static final String SERVICE_ACCOUNT = "serviceAccount"; - - private String _projectId; - private String _p12Filename; - private File _p12File; - private String _serviceAccount; - private String _passwordSet; - private String _password; - private AuthCredentials _authCredentials; - private DatastoreOptions _options; - - /** - * Generate a configuration from a properties file - * - * @param propsFile the properties filename - * @return the configuration - * @throws IOException if unable to read the properties file - */ - public static GCloudConfiguration fromFile(String propsFile) - throws IOException - { - if (propsFile == null) - throw new IllegalArgumentException ("Null properties file"); - - File f = new File(propsFile); - if (!f.exists()) - throw new IllegalArgumentException("No such file "+f.getAbsolutePath()); - Properties props = new Properties(); - try (FileInputStream is=new FileInputStream(f)) - { - props.load(is); - } - - GCloudConfiguration config = new GCloudConfiguration(); - config.setProjectId(props.getProperty(PROJECT_ID)); - config.setP12File(props.getProperty(P12)); - config.setPassword(props.getProperty(PASSWORD)); - config.setServiceAccount(props.getProperty(SERVICE_ACCOUNT)); - return config; - } - - - - public String getProjectId() - { - return _projectId; - } - - public File getP12File() - { - return _p12File; - } - - public String getServiceAccount() - { - return _serviceAccount; - } - - - public void setProjectId(String projectId) - { - checkForModification(); - _projectId = projectId; - } - - public void setP12File (String file) - { - checkForModification(); - _p12Filename = file; - - } - - - public void setServiceAccount (String serviceAccount) - { - checkForModification(); - _serviceAccount = serviceAccount; - } - - - public void setPassword (String pwd) - { - checkForModification(); - _passwordSet = pwd; - - } - - - public DatastoreOptions getDatastoreOptions () - throws Exception - { - if (_options == null) - { - if (_passwordSet == null && _p12Filename == null && _serviceAccount == null) - { - //When no values are explicitly presented for auth info, we are either running - //1. inside GCE environment, in which case all auth info is derived from the environment - //2. outside the GCE environment, but using a local gce dev server, in which case you - // need to set the following 2 environment/system properties - // DATASTORE_HOST: eg http://localhost:9999 - this is the host and port of a local development server - // DATASTORE_DATASET: eg myProj - this is the name of your project - _options = DatastoreOptions.defaultInstance(); - } - else - { - //When running externally to GCE, you need to provide - //explicit auth info. You can either set the projectId explicitly, or you can set the - //DATASTORE_DATASET env/system property - _p12File = new File(_p12Filename); - Password p = new Password(_passwordSet); - _password = p.toString(); - _options = DatastoreOptions.builder() - .projectId(_projectId) - .authCredentials(getAuthCredentials()) - .build(); - } - } - return _options; - } - - public AuthCredentials getAuthCredentials() - throws Exception - { - if (_authCredentials == null) - { - if (_password == null) - throw new IllegalStateException("No password"); - - if (_p12File == null || !_p12File.exists()) - throw new IllegalStateException("No p12 file: "+(_p12File==null?"null":_p12File.getAbsolutePath())); - - if (_serviceAccount == null) - throw new IllegalStateException("No service account"); - - char[] pwdChars = _password.toCharArray(); - KeyStore keystore = KeyStore.getInstance("PKCS12"); - keystore.load(new FileInputStream(getP12File()), pwdChars); - PrivateKey privateKey = (PrivateKey) keystore.getKey("privatekey", pwdChars); - _authCredentials = AuthCredentials.createFor(getServiceAccount(), privateKey); - } - return _authCredentials; - } - - /** - * @throws IllegalStateException - */ - protected void checkForModification () throws IllegalStateException - { - if (_authCredentials != null || _options != null) - throw new IllegalStateException("Cannot modify auth configuration after datastore initialized"); - } -} diff --git a/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java b/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java index 7a14c2e3059..cd5a86b98cb 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java +++ b/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStore.java @@ -19,24 +19,6 @@ package org.eclipse.jetty.gcloud.session; -import com.google.gcloud.datastore.Blob; -import com.google.gcloud.datastore.BlobValue; -import com.google.gcloud.datastore.Datastore; -import com.google.gcloud.datastore.DatastoreException; -import com.google.gcloud.datastore.DatastoreFactory; -import com.google.gcloud.datastore.Entity; -import com.google.gcloud.datastore.Key; -import com.google.gcloud.datastore.KeyFactory; -import com.google.gcloud.datastore.ProjectionEntity; -import com.google.gcloud.datastore.Query; -import com.google.gcloud.datastore.QueryResults; -import com.google.gcloud.datastore.StructuredQuery; -import com.google.gcloud.datastore.StructuredQuery.CompositeFilter; -import com.google.gcloud.datastore.StructuredQuery.KeyQueryBuilder; -import com.google.gcloud.datastore.StructuredQuery.Projection; -import com.google.gcloud.datastore.StructuredQuery.ProjectionEntityQueryBuilder; -import com.google.gcloud.datastore.StructuredQuery.PropertyFilter; - import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.util.HashSet; @@ -54,6 +36,20 @@ import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; +import com.google.cloud.datastore.Blob; +import com.google.cloud.datastore.BlobValue; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreException; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyFactory; +import com.google.cloud.datastore.ProjectionEntity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.StructuredQuery.CompositeFilter; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; + /** * GCloudSessionDataStore * @@ -80,12 +76,13 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore public static final int DEFAULT_MAX_RETRIES = 5; public static final int DEFAULT_BACKOFF_MS = 1000; - private GCloudConfiguration _config; private Datastore _datastore; private KeyFactory _keyFactory; private int _maxResults = DEFAULT_MAX_QUERY_RESULTS; private int _maxRetries = DEFAULT_MAX_RETRIES; private int _backoff = DEFAULT_BACKOFF_MS; + + private boolean _dsProvided = false; @@ -118,13 +115,10 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore @Override protected void doStart() throws Exception { - - if (_config == null) - throw new IllegalStateException("No DataStore configuration"); - - _datastore = DatastoreFactory.instance().get(_config.getDatastoreOptions()); - _keyFactory = _datastore.newKeyFactory().kind(KIND); - + if (!_dsProvided) + _datastore = DatastoreOptions.defaultInstance().service(); + + _keyFactory = _datastore.newKeyFactory().kind(KIND); super.doStart(); } @@ -134,21 +128,17 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore @Override protected void doStop() throws Exception { + if (!_dsProvided) + _datastore = null; super.doStop(); } - - public void setGCloudConfiguration (GCloudConfiguration cfg) + public void setDatastore (Datastore datastore) { - _config = cfg; + _datastore = datastore; + _dsProvided = true; } - public GCloudConfiguration getGCloudConfiguration () - { - return _config; - } - - public int getMaxResults() { return _maxResults; @@ -209,13 +199,14 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore try { //get up to maxResult number of sessions that have expired - ProjectionEntityQueryBuilder pbuilder = Query.projectionEntityQueryBuilder(); - pbuilder.projection(Projection.property(ID), Projection.property(LASTNODE), Projection.property(EXPIRY)); - pbuilder.filter(CompositeFilter.and(PropertyFilter.gt(EXPIRY, 0), PropertyFilter.le(EXPIRY, now))); - pbuilder.limit(_maxResults); - pbuilder.kind(KIND); - StructuredQuery pquery = pbuilder.build(); - QueryResults presults = _datastore.run(pquery); + Query query = Query.projectionEntityQueryBuilder() + .kind(KIND) + .projection(ID, LASTNODE, EXPIRY) + .filter(CompositeFilter.and(PropertyFilter.gt(EXPIRY, 0), PropertyFilter.le(EXPIRY, now))) + .limit(_maxResults) + .build(); + + QueryResults presults = _datastore.run(query); while (presults.hasNext()) { @@ -249,7 +240,7 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore } } - //reconcile against ids that the SessionDataStore thinks are expired + //reconcile against ids that the SessionCache thinks are expired Set tmp = new HashSet(candidates); tmp.removeAll(expired); if (!tmp.isEmpty()) @@ -262,12 +253,12 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore { try { - KeyQueryBuilder kbuilder = Query.keyQueryBuilder(); - kbuilder.filter(PropertyFilter.eq(ID, s)); - kbuilder.kind(KIND); - StructuredQuery kq = kbuilder.build(); - QueryResults kresults = _datastore.run(kq); - if (!kresults.hasNext()) + Query q = Query.keyQueryBuilder() + .kind(KIND) + .filter(PropertyFilter.eq(ID, s)) + .build(); + QueryResults res = _datastore.run(q); + if (!res.hasNext()) expired.add(s); //not in db, can be expired } catch (Exception e) @@ -297,13 +288,14 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore @Override public boolean exists(String id) throws Exception { - ProjectionEntityQueryBuilder pbuilder = Query.projectionEntityQueryBuilder(); - pbuilder.kind(KIND); - pbuilder.projection(Projection.property(EXPIRY)); - pbuilder.filter(PropertyFilter.eq(ID, id)); + Query query = Query.projectionEntityQueryBuilder() + .kind(KIND) + .projection(EXPIRY) + .filter(PropertyFilter.eq(ID, id)) + .build(); - StructuredQuery pquery = pbuilder.build(); - QueryResults presults = _datastore.run(pquery); + + QueryResults presults = _datastore.run(query); if (presults.hasNext()) { @@ -340,7 +332,7 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore } catch (DatastoreException e) { - if (e.code().retryable()) + if (e.retryable()) { if (LOG.isDebugEnabled()) LOG.debug("Datastore put retry {} waiting {}ms", attempts, backoff); @@ -418,7 +410,7 @@ public class GCloudSessionDataStore extends AbstractSessionDataStore .set(LASTNODE,session.getLastNode()) .set(EXPIRY, session.getExpiry()) .set(MAXINACTIVE, session.getMaxInactiveMs()) - .set(ATTRIBUTES, BlobValue.builder(Blob.copyFrom(baos.toByteArray())).indexed(false).build()).build(); + .set(ATTRIBUTES, BlobValue.builder(Blob.copyFrom(baos.toByteArray())).excludeFromIndexes(true).build()).build(); return entity; diff --git a/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStoreFactory.java b/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStoreFactory.java index 1f920236c5d..8d6759916f0 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStoreFactory.java +++ b/jetty-gcloud/jetty-gcloud-session-manager/src/main/java/org/eclipse/jetty/gcloud/session/GCloudSessionDataStoreFactory.java @@ -30,20 +30,10 @@ import org.eclipse.jetty.server.session.SessionHandler; */ public class GCloudSessionDataStoreFactory extends AbstractSessionDataStoreFactory { - private GCloudConfiguration _config; private int _maxRetries; private int _backoffMs; - public GCloudConfiguration getGCloudConfiguration() - { - return _config; - } - - public void setGCloudConfiguration(GCloudConfiguration config) - { - _config = config; - } public int getMaxRetries() { @@ -73,7 +63,6 @@ public class GCloudSessionDataStoreFactory extends AbstractSessionDataStoreFacto public SessionDataStore getSessionDataStore(SessionHandler handler) throws Exception { GCloudSessionDataStore ds = new GCloudSessionDataStore(); - ds.setGCloudConfiguration(getGCloudConfiguration()); ds.setBackoffMs(getBackoffMs()); ds.setMaxRetries(getMaxRetries()); ds.setGracePeriodSec(getGracePeriodSec()); diff --git a/jetty-gcloud/jetty-gcloud-session-manager/src/test/java/org/eclipse/jetty/gcloud/session/GCloudSessionTester.java b/jetty-gcloud/jetty-gcloud-session-manager/src/test/java/org/eclipse/jetty/gcloud/session/GCloudSessionTester.java index 777903ca8bf..4e94500f746 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/src/test/java/org/eclipse/jetty/gcloud/session/GCloudSessionTester.java +++ b/jetty-gcloud/jetty-gcloud-session-manager/src/test/java/org/eclipse/jetty/gcloud/session/GCloudSessionTester.java @@ -44,11 +44,6 @@ public class GCloudSessionTester loginService.setConfig( "../../jetty-distribution/target/distribution/demo-base/resources/realm.properties" ); server.addBean( loginService ); - GCloudConfiguration config = new GCloudConfiguration(); - config.setProjectId(args[0]); - config.setP12File(args[1]); - config.setPassword(args[2]); - config.setServiceAccount(args[3]); DefaultSessionIdManager idmgr = new DefaultSessionIdManager(server); idmgr.setWorkerName("w1"); @@ -60,7 +55,7 @@ public class GCloudSessionTester webapp.setWar("../../jetty-distribution/target/distribution/demo-base/webapps/test.war"); webapp.addAliasCheck(new AllowSymLinkAliasChecker()); GCloudSessionDataStore ds = new GCloudSessionDataStore(); - ds.setGCloudConfiguration(config); + DefaultSessionCache ss = new DefaultSessionCache(webapp.getSessionHandler()); webapp.getSessionHandler().setSessionCache(ss); ss.setSessionDataStore(ds); diff --git a/jetty-gcloud/pom.xml b/jetty-gcloud/pom.xml index 3d571b8a56d..0a4d85f5612 100644 --- a/jetty-gcloud/pom.xml +++ b/jetty-gcloud/pom.xml @@ -13,7 +13,7 @@ Jetty :: GCloud - 0.0.8 + 0.2.3 diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ClientCrossContextSessionTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ClientCrossContextSessionTest.java index ad1ac384160..bd776456335 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ClientCrossContextSessionTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ClientCrossContextSessionTest.java @@ -43,7 +43,7 @@ public class ClientCrossContextSessionTest extends AbstractClientCrossContextSes @Override public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) { - return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ForwardedSessionTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ForwardedSessionTest.java index 4d2e9c0b6e5..a1d3e0ef4d0 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ForwardedSessionTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ForwardedSessionTest.java @@ -43,6 +43,6 @@ public class ForwardedSessionTest extends AbstractForwardedSessionTest @Override public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) { - return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy); } } diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/GCloudSessionTestSupport.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/GCloudSessionTestSupport.java index cb66b374b80..0df93b521dc 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/GCloudSessionTestSupport.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/GCloudSessionTestSupport.java @@ -22,40 +22,20 @@ package org.eclipse.jetty.gcloud.session; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; -import java.nio.file.Files; import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import java.util.Locale; import java.util.Set; -import org.eclipse.jetty.util.IO; -import org.eclipse.jetty.util.resource.JarResource; -import org.eclipse.jetty.util.resource.Resource; - -import com.google.api.client.util.Strings; -import com.google.gcloud.datastore.Datastore; -import com.google.gcloud.datastore.DatastoreFactory; -import com.google.gcloud.datastore.Entity; -import com.google.gcloud.datastore.GqlQuery; -import com.google.gcloud.datastore.Key; -import com.google.gcloud.datastore.ProjectionEntity; -import com.google.gcloud.datastore.Query; -import com.google.gcloud.datastore.Query.ResultType; -import com.google.gcloud.datastore.QueryResults; -import com.google.gcloud.datastore.StructuredQuery; -import com.google.gcloud.datastore.StructuredQuery.Projection; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.GqlQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.Query.ResultType; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.testing.LocalDatastoreHelper; /** * GCloudSessionTestSupport @@ -63,240 +43,62 @@ import com.google.gcloud.datastore.StructuredQuery.Projection; * */ public class GCloudSessionTestSupport -{ - - private static class ProcessOutputReader implements Runnable - { - private InputStream _is; - private String _startupSentinel; - private BufferedReader _reader; - - public ProcessOutputReader (InputStream is, String startupSentinel) - throws Exception - { - _is = is; - _startupSentinel = startupSentinel; - _reader = new BufferedReader(new InputStreamReader(_is)); - if (!Strings.isNullOrEmpty(_startupSentinel)) - { - String line; - while ((line = _reader.readLine()) != (null) && !line.contains(_startupSentinel)) - { - //System.err.println(line); - } - } - } - - - public void run() - { - String line; - try - { - while ((line = _reader.readLine()) != (null)) - { - } - } - catch (IOException ignore) - { - /* ignore */ - } - finally - { - IO.close(_reader); - } - } - } - - - public static String DEFAULT_PROJECTID = "jetty9-work"; - public static String DEFAULT_PORT = "8088"; - public static String DEFAULT_HOST = "http://localhost:"+DEFAULT_PORT; - public static String DEFAULT_GCD_ZIP = "gcd-v1beta2-rev1-2.1.2b.zip"; - public static String DEFAULT_GCD_UNPACKED = "gcd-v1beta2-rev1-2.1.2b"; - public static String DEFAULT_DOWNLOAD_URL = "http://storage.googleapis.com/gcd/tools/"; - - - String _projectId; - String _testServerUrl; - String _testPort; - File _datastoreDir; - File _gcdInstallDir; - File _gcdUnpackedDir; +{ + LocalDatastoreHelper _helper = LocalDatastoreHelper.create(1.0); Datastore _ds; - - public GCloudSessionTestSupport (File gcdInstallDir) - { - _gcdInstallDir = gcdInstallDir; - if (_gcdInstallDir == null) - _gcdInstallDir = new File (System.getProperty("java.io.tmpdir")); - - _projectId = System.getProperty("DATASTORE_DATASET", System.getenv("DATASTORE_DATASET")); - if (_projectId == null) - { - _projectId = DEFAULT_PROJECTID; - System.setProperty("DATASTORE_DATASET", _projectId); - } - _testServerUrl = System.getProperty("DATASTORE_HOST", System.getenv("DATASTORE_HOST")); - if (_testServerUrl == null) - { - _testServerUrl = DEFAULT_HOST; - _testPort = DEFAULT_PORT; - System.setProperty("DATASTORE_HOST", _testServerUrl); - } - else - { - int i = _testServerUrl.lastIndexOf(':'); - _testPort = _testServerUrl.substring(i+1); - } - } - + + + public GCloudSessionTestSupport () { - this(null); + DatastoreOptions options = _helper.options(); + _ds = options.service(); } - public GCloudConfiguration getConfiguration () - { - return new GCloudConfiguration(); - } - - + + public void setUp() - throws Exception + throws Exception { - downloadGCD(); - createDatastore(); - startDatastore(); + _helper.start(); } - - - public void downloadGCD() - throws Exception - { - File zipFile = new File (_gcdInstallDir, DEFAULT_GCD_ZIP); - _gcdUnpackedDir = new File (_gcdInstallDir, DEFAULT_GCD_UNPACKED); - File gcdSh = new File (_gcdUnpackedDir, "gcd.sh"); - if (gcdSh.exists()) - return; - - - if (_gcdInstallDir.exists() && !zipFile.exists()) - { - //download it - ReadableByteChannel rbc = Channels.newChannel(new URL(DEFAULT_DOWNLOAD_URL+DEFAULT_GCD_ZIP).openStream()); - try (FileOutputStream fos = new FileOutputStream(zipFile)) - { - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - } - } - - if (zipFile.exists()) - { - //unpack it - Resource zipResource = JarResource.newJarResource(Resource.newResource(zipFile)); - zipResource.copyTo(_gcdInstallDir); - } - - System.err.println("GCD downloaded and unpacked"); - } - - - - public void createDatastore () - throws Exception - { - - _datastoreDir = Files.createTempDirectory("gcloud-sessions").toFile(); - _datastoreDir.deleteOnExit(); - - ProcessBuilder processBuilder = new ProcessBuilder(); - processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); - processBuilder.directory(_datastoreDir); - if (System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows")) - { - processBuilder.command("cmd", "/C", new File(_gcdUnpackedDir, "gcd.cmd").getAbsolutePath(), "create", "-p", _projectId, _projectId); - processBuilder.redirectOutput(new File("NULL:")); - } - else - { - processBuilder.redirectOutput(new File("/tmp/run.out")); - processBuilder.command("bash", new File(_gcdUnpackedDir, "gcd.sh").getAbsolutePath(), "create", "-p",_projectId, _projectId); - } - Process temp = processBuilder.start(); - System.err.println("Create outcome: "+temp.waitFor()); - } - - - public void startDatastore() - throws Exception - { - //start the datastore for the test - ProcessBuilder processBuilder = new ProcessBuilder(); - processBuilder.directory(_datastoreDir); - processBuilder.redirectErrorStream(true); - if (System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows")) - { - processBuilder.command("cmd", "/C", new File(_gcdUnpackedDir, "gcd.cmd").getAbsolutePath(), "start", "--testing", "--allow_remote_shutdown","--port="+_testPort, _projectId); - } - else - { - processBuilder.command("bash", new File(_gcdUnpackedDir, "gcd.sh").getAbsolutePath(), "start", "--testing", "--allow_remote_shutdown", "--port="+_testPort, _projectId); - } - - System.err.println("Starting datastore"); - Process temp = processBuilder.start(); - ProcessOutputReader reader = new ProcessOutputReader(temp.getInputStream(), "Dev App Server is now running"); - Thread readerThread = new Thread(reader, "GCD reader"); - readerThread.setDaemon(true); - readerThread.start(); - } - - public void stopDatastore() - throws Exception - { - //Send request to terminate test datastore - URL url = new URL("http", "localhost", Integer.parseInt(_testPort.trim()), "/_ah/admin/quit"); - HttpURLConnection con = (HttpURLConnection) url.openConnection(); - con.setRequestMethod("POST"); - con.setDoOutput(true); - con.setDoInput(true); - OutputStream out = con.getOutputStream(); - out.write("".getBytes()); - out.flush(); - InputStream in = con.getInputStream(); - while (in.read() != -1) - { - // consume input - - } - System.err.println("Stop issued"); - } - - - public void clearDatastore() + public Datastore getDatastore () { - org.eclipse.jetty.util.IO.delete(_datastoreDir); + return _ds; } - + + public void tearDown() - throws Exception + throws Exception { - stopDatastore(); - clearDatastore(); + _helper.stop(); } - public void ensureDatastore() - throws Exception + + + public Set getSessionIds () throws Exception { - if (_ds == null) - _ds = DatastoreFactory.instance().get(getConfiguration().getDatastoreOptions()); + HashSet ids = new HashSet(); + GqlQuery.Builder builder = Query.gqlQueryBuilder(ResultType.ENTITY, "select * from "+GCloudSessionDataStore.KIND); + + Query query = builder.build(); + + QueryResults results = _ds.run(query); + assertNotNull(results); + while (results.hasNext()) + { + Entity e = results.next(); + ids.add(e.getString("id")); + } + + return ids; } + public void listSessions () throws Exception { - ensureDatastore(); + GqlQuery.Builder builder = Query.gqlQueryBuilder(ResultType.ENTITY, "select * from "+GCloudSessionDataStore.KIND); Query query = builder.build(); @@ -313,66 +115,38 @@ public class GCloudSessionTestSupport System.err.println("END OF SESSIONS::::::::"); } - public Set getSessionIds () throws Exception - { - HashSet ids = new HashSet(); - ensureDatastore(); - GqlQuery.Builder builder = Query.gqlQueryBuilder(ResultType.ENTITY, "select * from "+GCloudSessionDataStore.KIND); - - Query query = builder.build(); - - QueryResults results = _ds.run(query); - assertNotNull(results); - while (results.hasNext()) - { - Entity e = results.next(); - ids.add(e.getString("id")); - } - - return ids; - } - public void assertSessions(int count) throws Exception - { - ensureDatastore(); - StructuredQuery keyOnlyProjectionQuery = Query.projectionEntityQueryBuilder() - .kind(GCloudSessionDataStore.KIND) - .projection(Projection.property("__key__")) - .limit(100) - .build(); - QueryResults results = _ds.run(keyOnlyProjectionQuery); + { + Query query = Query.keyQueryBuilder().kind(GCloudSessionDataStore.KIND).build(); + QueryResults results = _ds.run(query); assertNotNull(results); int actual = 0; while (results.hasNext()) { - ProjectionEntity e = results.next(); + results.next(); ++actual; } assertEquals(count, actual); } - + public void deleteSessions () throws Exception { - ensureDatastore(); - StructuredQuery keyOnlyProjectionQuery = Query.projectionEntityQueryBuilder() - .kind(GCloudSessionDataStore.KIND) - .projection(Projection.property("__key__")) - .limit(100) - .build(); - QueryResults results = _ds.run(keyOnlyProjectionQuery); + Query query = Query.keyQueryBuilder().kind(GCloudSessionDataStore.KIND).build(); + QueryResults results = _ds.run(query); + if (results != null) { List keys = new ArrayList(); - + while (results.hasNext()) { - ProjectionEntity pe = results.next(); - keys.add(pe.key()); + keys.add(results.next()); } - + _ds.delete(keys.toArray(new Key[keys.size()])); } - + assertSessions(0); } + } diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/GCloudTestServer.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/GCloudTestServer.java index 8c77f5fe6d8..9218df72332 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/GCloudTestServer.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/GCloudTestServer.java @@ -37,9 +37,9 @@ public class GCloudTestServer extends AbstractTestServer * @param scavengePeriod * @param sessionIdMgrConfig */ - public GCloudTestServer(int port, int maxInactivePeriod, int scavengePeriod, int evictionPolicy, GCloudConfiguration config) + public GCloudTestServer(int port, int maxInactivePeriod, int scavengePeriod, int evictionPolicy) { - super(port, maxInactivePeriod, scavengePeriod, evictionPolicy, config); + super(port, maxInactivePeriod, scavengePeriod, evictionPolicy); } @@ -53,7 +53,7 @@ public class GCloudTestServer extends AbstractTestServer SessionHandler handler = new SessionHandler(); handler.setSessionIdManager(_sessionIdManager); GCloudSessionDataStore ds = new GCloudSessionDataStore(); - ds.setGCloudConfiguration((GCloudConfiguration)_config); + ds.setDatastore(GCloudTestSuite.__testSupport.getDatastore()); DefaultSessionCache ss = new DefaultSessionCache(handler); ss.setSessionDataStore(ds); handler.setSessionCache(ss); diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ImmediateSaveTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ImmediateSaveTest.java index f87a54521d6..53cf28ae464 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ImmediateSaveTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ImmediateSaveTest.java @@ -48,7 +48,7 @@ public class ImmediateSaveTest extends AbstractImmediateSaveTest public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) { - return new GCloudTestServer(port, max, scavenge, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()) + return new GCloudTestServer(port, max, scavenge, evictionPolicy) { public SessionHandler newSessionHandler() { diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ImmortalSessionTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ImmortalSessionTest.java index 5b0963c2115..40eb998d6fd 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ImmortalSessionTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ImmortalSessionTest.java @@ -45,7 +45,7 @@ public class ImmortalSessionTest extends AbstractImmortalSessionTest @Override public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) { - return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/InvalidationSessionTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/InvalidationSessionTest.java index bcbc45cd61b..461d57d1a2a 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/InvalidationSessionTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/InvalidationSessionTest.java @@ -47,7 +47,7 @@ public class InvalidationSessionTest extends AbstractInvalidationSessionTest @Override public AbstractTestServer createServer(int port, int maxInactive, int scavengeInterval, int evictionPolicy) { - GCloudTestServer server = new GCloudTestServer(port, maxInactive, scavengeInterval, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()) + GCloudTestServer server = new GCloudTestServer(port, maxInactive, scavengeInterval, evictionPolicy) { /** * @see org.eclipse.jetty.gcloud.session.GCloudTestServer#newSessionManager() diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/LastAccessTimeTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/LastAccessTimeTest.java index bf5a68e6be1..e28410ee9da 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/LastAccessTimeTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/LastAccessTimeTest.java @@ -44,7 +44,7 @@ public class LastAccessTimeTest extends AbstractLastAccessTimeTest @Override public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) { - return new GCloudTestServer(port, max, scavenge, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, max, scavenge, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/LocalSessionScavengingTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/LocalSessionScavengingTest.java index f84b8072c07..1ea289e57c5 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/LocalSessionScavengingTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/LocalSessionScavengingTest.java @@ -45,7 +45,7 @@ public class LocalSessionScavengingTest extends AbstractLocalSessionScavengingTe @Override public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) { - return new GCloudTestServer(port, max, scavenge, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, max, scavenge, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/NewSessionTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/NewSessionTest.java index b0cd7fe8f03..fa70da1b198 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/NewSessionTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/NewSessionTest.java @@ -52,7 +52,7 @@ public class NewSessionTest extends AbstractNewSessionTest @Override public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) { - return new GCloudTestServer(port, max, scavenge, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, max, scavenge, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/OrphanedSessionTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/OrphanedSessionTest.java index b163aae4496..ecec2fd6351 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/OrphanedSessionTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/OrphanedSessionTest.java @@ -46,7 +46,7 @@ public class OrphanedSessionTest extends AbstractOrphanedSessionTest @Override public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) { - return new GCloudTestServer(port, max, scavenge, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, max, scavenge, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ReentrantRequestSessionTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ReentrantRequestSessionTest.java index a984d316e11..22b549d45ee 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ReentrantRequestSessionTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ReentrantRequestSessionTest.java @@ -45,7 +45,7 @@ public class ReentrantRequestSessionTest extends AbstractReentrantRequestSession @Override public AbstractTestServer createServer(int port,int max, int scavengePeriod,int evictionPolicy) { - return new GCloudTestServer(port, max, scavengePeriod, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, max, scavengePeriod, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/RemoveSessionTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/RemoveSessionTest.java index a51ea0be72b..22f6cf56e38 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/RemoveSessionTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/RemoveSessionTest.java @@ -48,7 +48,7 @@ public class RemoveSessionTest extends AbstractRemoveSessionTest @Override public AbstractTestServer createServer(int port, int max, int scavenge,int evictionPolicy) { - return new GCloudTestServer(port, max, scavenge, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, max, scavenge, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SameNodeLoadTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SameNodeLoadTest.java index fbe95f52572..a677e003cff 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SameNodeLoadTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SameNodeLoadTest.java @@ -46,7 +46,7 @@ public class SameNodeLoadTest extends AbstractSameNodeLoadTest @Override public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) { - return new GCloudTestServer(port, max, scavenge, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, max, scavenge, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ServerCrossContextSessionTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ServerCrossContextSessionTest.java index 243077afc05..494c8ec4664 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ServerCrossContextSessionTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/ServerCrossContextSessionTest.java @@ -41,7 +41,7 @@ public class ServerCrossContextSessionTest extends AbstractServerCrossContextSes @Override public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) { - return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionExpiryTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionExpiryTest.java index 21f98d70e50..c76545edfbf 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionExpiryTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionExpiryTest.java @@ -50,7 +50,7 @@ public class SessionExpiryTest extends AbstractSessionExpiryTest @Override public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) { - return new GCloudTestServer(port, max, scavenge, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, max, scavenge, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionInvalidateAndCreateTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionInvalidateAndCreateTest.java index 58b67fead47..246472349bb 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionInvalidateAndCreateTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionInvalidateAndCreateTest.java @@ -45,7 +45,7 @@ public class SessionInvalidateAndCreateTest extends AbstractSessionInvalidateAnd @Override public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) { - return new GCloudTestServer(port, max, scavenge, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, max, scavenge, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionMigrationTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionMigrationTest.java index a6727aac9fa..f10551ef2e3 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionMigrationTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionMigrationTest.java @@ -45,7 +45,7 @@ public class SessionMigrationTest extends AbstractSessionMigrationTest @Override public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) { - return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionRenewTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionRenewTest.java index f5a863f8008..d6d8e7d6fcf 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionRenewTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionRenewTest.java @@ -49,7 +49,7 @@ public class SessionRenewTest extends AbstractSessionRenewTest @Override public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) { - return new GCloudTestServer(port,max, scavenge, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port,max, scavenge, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionValueSavingTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionValueSavingTest.java index f9a29433a97..42e03ef2ffb 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionValueSavingTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/SessionValueSavingTest.java @@ -44,7 +44,7 @@ public class SessionValueSavingTest extends AbstractSessionValueSavingTest @Override public AbstractTestServer createServer(int port, int max, int scavenge, int evictionPolicy) { - return new GCloudTestServer(port, max, scavenge, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, max, scavenge, evictionPolicy); } @Test diff --git a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/StopSessionManagerPreserveSessionTest.java b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/StopSessionManagerPreserveSessionTest.java index 5761c30d267..820263aca3d 100644 --- a/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/StopSessionManagerPreserveSessionTest.java +++ b/tests/test-sessions/test-gcloud-sessions/src/test/java/org/eclipse/jetty/gcloud/session/StopSessionManagerPreserveSessionTest.java @@ -62,7 +62,7 @@ public class StopSessionManagerPreserveSessionTest extends AbstractStopSessionMa @Override public AbstractTestServer createServer(int port, int maxInactiveMs, int scavengeMs,int evictionPolicy) { - return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy, GCloudTestSuite.__testSupport.getConfiguration()); + return new GCloudTestServer(port, maxInactiveMs, scavengeMs, evictionPolicy); } /** * @see org.eclipse.jetty.server.session.AbstractStopSessionManagerPreserveSessionTest#configureSessionManagement(org.eclipse.jetty.servlet.ServletContextHandler) diff --git a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanTestSessionServer.java b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanTestSessionServer.java index 5f615d1072c..6af0f11ee15 100644 --- a/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanTestSessionServer.java +++ b/tests/test-sessions/test-infinispan-sessions/src/test/java/org/eclipse/jetty/server/session/InfinispanTestSessionServer.java @@ -33,7 +33,7 @@ public class InfinispanTestSessionServer extends AbstractTestServer public InfinispanTestSessionServer(int port, int maxInactivePeriod, int scavengePeriod, int evictionPolicy, BasicCache config) { - super(port, maxInactivePeriod, scavengePeriod, evictionPolicy, config); + super(port, maxInactivePeriod, scavengePeriod, evictionPolicy); } diff --git a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestServer.java b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestServer.java index 46b6ba962fe..b71a4139079 100644 --- a/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestServer.java +++ b/tests/test-sessions/test-jdbc-sessions/src/test/java/org/eclipse/jetty/server/session/JdbcTestServer.java @@ -81,12 +81,12 @@ public class JdbcTestServer extends AbstractTestServer public JdbcTestServer(int port, int maxInactivePeriod, int scavengePeriod, int idlePassivatePeriod, String connectionUrl) { - super(port, maxInactivePeriod, scavengePeriod, idlePassivatePeriod, connectionUrl); + super(port, maxInactivePeriod, scavengePeriod, idlePassivatePeriod); } public JdbcTestServer(int port, int maxInactivePeriod, int scavengePeriod, int idlePassivatePeriod) { - super(port, maxInactivePeriod, scavengePeriod, idlePassivatePeriod, DEFAULT_CONNECTION_URL); + super(port, maxInactivePeriod, scavengePeriod, idlePassivatePeriod); }