mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-926: Set JDBC to batch mode and just do operations one at a time.
This commit is contained in:
@@ -45,6 +45,7 @@ import org.apache.guacamole.auth.jdbc.security.SaltService;
|
||||
import org.apache.guacamole.auth.jdbc.security.SecureRandomSaltService;
|
||||
import org.apache.guacamole.auth.jdbc.permission.SystemPermissionService;
|
||||
import org.apache.guacamole.auth.jdbc.user.UserService;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
|
||||
import org.apache.guacamole.auth.jdbc.permission.ConnectionGroupPermissionMapper;
|
||||
import org.apache.guacamole.auth.jdbc.permission.ConnectionGroupPermissionService;
|
||||
@@ -126,6 +127,11 @@ public class JDBCAuthenticationProviderModule extends MyBatisModule {
|
||||
// Transaction factory
|
||||
bindTransactionFactoryType(JdbcTransactionFactory.class);
|
||||
|
||||
// Set the JDBC Auth provider to use batch execution when possible
|
||||
bindConfigurationSetting(configuration -> {
|
||||
configuration.setDefaultExecutorType(ExecutorType.BATCH);
|
||||
});
|
||||
|
||||
// Add MyBatis mappers
|
||||
addMapperClass(ConnectionMapper.class);
|
||||
addMapperClass(ConnectionGroupMapper.class);
|
||||
|
@@ -25,16 +25,14 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.auth.jdbc.base.RestrictedObject;
|
||||
import org.apache.guacamole.auth.jdbc.base.JDBCDirectory;
|
||||
import org.apache.guacamole.net.auth.ActiveConnection;
|
||||
import org.apache.guacamole.net.auth.Directory;
|
||||
|
||||
/**
|
||||
* Implementation of a Directory which contains all currently-active
|
||||
* connections.
|
||||
*/
|
||||
public class ActiveConnectionDirectory extends RestrictedObject
|
||||
implements Directory<ActiveConnection> {
|
||||
public class ActiveConnectionDirectory extends JDBCDirectory<ActiveConnection> {
|
||||
|
||||
/**
|
||||
* Service for retrieving and manipulating active connections.
|
||||
|
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.auth.jdbc.base;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.net.auth.AtomicDirectoryOperation;
|
||||
import org.apache.guacamole.net.auth.Directory;
|
||||
import org.apache.guacamole.net.auth.Identifiable;
|
||||
import org.mybatis.guice.transactional.Transactional;
|
||||
|
||||
/**
|
||||
* An implementation of Directory that uses database transactions to guarantee
|
||||
* atomicity for any operations supplied to tryAtomically().
|
||||
*/
|
||||
public abstract class JDBCDirectory<ObjectType extends Identifiable>
|
||||
extends RestrictedObject implements Directory<ObjectType> {
|
||||
|
||||
@Transactional
|
||||
public void tryAtomically(AtomicDirectoryOperation<ObjectType> operation)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Execute the operation atomically - the @Transactional annotation
|
||||
// specifies that the entire operation will be performed in a transaction
|
||||
operation.executeOperation(true, this);
|
||||
|
||||
}
|
||||
}
|
@@ -25,17 +25,15 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.auth.jdbc.base.RestrictedObject;
|
||||
import org.apache.guacamole.auth.jdbc.base.JDBCDirectory;
|
||||
import org.apache.guacamole.net.auth.Connection;
|
||||
import org.apache.guacamole.net.auth.Directory;
|
||||
import org.mybatis.guice.transactional.Transactional;
|
||||
|
||||
/**
|
||||
* Implementation of the Connection Directory which is driven by an underlying,
|
||||
* arbitrary database.
|
||||
*/
|
||||
public class ConnectionDirectory extends RestrictedObject
|
||||
implements Directory<Connection> {
|
||||
public class ConnectionDirectory extends JDBCDirectory<Connection> {
|
||||
|
||||
/**
|
||||
* Service for managing connection objects.
|
||||
|
@@ -25,17 +25,15 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.auth.jdbc.base.RestrictedObject;
|
||||
import org.apache.guacamole.auth.jdbc.base.JDBCDirectory;
|
||||
import org.apache.guacamole.net.auth.ConnectionGroup;
|
||||
import org.apache.guacamole.net.auth.Directory;
|
||||
import org.mybatis.guice.transactional.Transactional;
|
||||
|
||||
/**
|
||||
* Implementation of the ConnectionGroup Directory which is driven by an
|
||||
* underlying, arbitrary database.
|
||||
*/
|
||||
public class ConnectionGroupDirectory extends RestrictedObject
|
||||
implements Directory<ConnectionGroup> {
|
||||
public class ConnectionGroupDirectory extends JDBCDirectory<ConnectionGroup> {
|
||||
|
||||
/**
|
||||
* Service for managing connection group objects.
|
||||
|
@@ -24,8 +24,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.auth.jdbc.base.RestrictedObject;
|
||||
import org.apache.guacamole.net.auth.Directory;
|
||||
import org.apache.guacamole.auth.jdbc.base.JDBCDirectory;
|
||||
import org.apache.guacamole.net.auth.SharingProfile;
|
||||
import org.mybatis.guice.transactional.Transactional;
|
||||
|
||||
@@ -33,8 +32,7 @@ import org.mybatis.guice.transactional.Transactional;
|
||||
* Implementation of the SharingProfile Directory which is driven by an
|
||||
* underlying, arbitrary database.
|
||||
*/
|
||||
public class SharingProfileDirectory extends RestrictedObject
|
||||
implements Directory<SharingProfile> {
|
||||
public class SharingProfileDirectory extends JDBCDirectory<SharingProfile> {
|
||||
|
||||
/**
|
||||
* Service for managing sharing profile objects.
|
||||
|
@@ -25,8 +25,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.auth.jdbc.base.RestrictedObject;
|
||||
import org.apache.guacamole.net.auth.Directory;
|
||||
import org.apache.guacamole.auth.jdbc.base.JDBCDirectory;
|
||||
import org.apache.guacamole.net.auth.User;
|
||||
import org.mybatis.guice.transactional.Transactional;
|
||||
|
||||
@@ -34,8 +33,7 @@ import org.mybatis.guice.transactional.Transactional;
|
||||
* Implementation of the User Directory which is driven by an underlying,
|
||||
* arbitrary database.
|
||||
*/
|
||||
public class UserDirectory extends RestrictedObject
|
||||
implements Directory<User> {
|
||||
public class UserDirectory extends JDBCDirectory<User> {
|
||||
|
||||
/**
|
||||
* Service for managing user objects.
|
||||
|
@@ -24,8 +24,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.auth.jdbc.base.RestrictedObject;
|
||||
import org.apache.guacamole.net.auth.Directory;
|
||||
import org.apache.guacamole.auth.jdbc.base.JDBCDirectory;
|
||||
import org.apache.guacamole.net.auth.UserGroup;
|
||||
import org.mybatis.guice.transactional.Transactional;
|
||||
|
||||
@@ -33,8 +32,7 @@ import org.mybatis.guice.transactional.Transactional;
|
||||
* Implementation of the UserGroup Directory which is driven by an underlying,
|
||||
* arbitrary database.
|
||||
*/
|
||||
public class UserGroupDirectory extends RestrictedObject
|
||||
implements Directory<UserGroup> {
|
||||
public class UserGroupDirectory extends JDBCDirectory<UserGroup> {
|
||||
|
||||
/**
|
||||
* Service for managing user group objects.
|
||||
|
Reference in New Issue
Block a user