Merge "Add support for SAP MaxDB"
This commit is contained in:
commit
c798b4cc20
@ -111,6 +111,49 @@ Sample database section in $site_path/etc/secure.config:
|
||||
password = secret_pasword
|
||||
----
|
||||
|
||||
[[createdb_maxdb]]
|
||||
=== SAP MaxDB
|
||||
|
||||
SAP MaxDB is a supported database for running Gerrit Code Review. However it is
|
||||
recommended only for environments where you intend to run Gerrit on an existing
|
||||
MaxDB installation to reduce administrative overhead.
|
||||
|
||||
In the MaxDB studio or using the SQLCLI command line interface create a user
|
||||
'gerrit2' with the user class 'RESOURCE' and a password <secret password>. This
|
||||
will also create an associated schema on the database.
|
||||
|
||||
To run Gerrit on MaxDB, you need to obtain the MaxDB JDBC driver. It can be
|
||||
found in your MaxDB installation at the following location:
|
||||
|
||||
- on Windows 64bit at "C:\Program Files\sdb\MaxDB\runtime\jar\sapdbc.jar"
|
||||
- on Linux at "/opt/sdb/MaxDB/runtime/jar/sapdbc.jar"
|
||||
|
||||
It needs to be stored in the 'lib' folder of the review site.
|
||||
|
||||
In the following sample database section it is assumed that the database name is
|
||||
'reviewdb' and the database is installed on localhost:
|
||||
|
||||
In $site_path/etc/gerrit.config:
|
||||
|
||||
----
|
||||
[database]
|
||||
type = maxdb
|
||||
database = reviewdb
|
||||
hostname = localhost
|
||||
username = gerrit2
|
||||
|
||||
----
|
||||
|
||||
In $site_path/etc/secure.config:
|
||||
|
||||
----
|
||||
[database]
|
||||
password = <secret password>
|
||||
----
|
||||
|
||||
Visit SAP MaxDB's link:http://maxdb.sap.com/documentation/[documentation] for further
|
||||
information regarding using SAP MaxDB.
|
||||
|
||||
|
||||
GERRIT
|
||||
------
|
||||
|
@ -39,5 +39,7 @@ public class DatabaseConfigModule extends AbstractModule {
|
||||
Names.named("oracle")).to(OracleInitializer.class);
|
||||
bind(DatabaseConfigInitializer.class).annotatedWith(
|
||||
Names.named("postgresql")).to(PostgreSQLInitializer.class);
|
||||
bind(DatabaseConfigInitializer.class).annotatedWith(
|
||||
Names.named("maxdb")).to(MaxDbInitializer.class);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed 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 com.google.gerrit.pgm.init;
|
||||
|
||||
import static com.google.gerrit.pgm.init.InitUtil.username;
|
||||
|
||||
public class MaxDbInitializer implements DatabaseConfigInitializer {
|
||||
|
||||
@Override
|
||||
public void initConfig(Section databaseSection) {
|
||||
final String defPort = "(maxdb default)";
|
||||
databaseSection.string("Server hostname", "hostname", "localhost");
|
||||
databaseSection.string("Server port", "port", defPort, true);
|
||||
databaseSection.string("Database name", "database", "reviewdb");
|
||||
databaseSection.string("Database username", "username", username());
|
||||
databaseSection.password("username", "password");
|
||||
}
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
delimiter #
|
||||
-- Gerrit 2 : MaxDB
|
||||
--
|
||||
|
||||
-- Indexes to support @Query
|
||||
--
|
||||
|
||||
-- *********************************************************************
|
||||
-- AccountAccess
|
||||
-- covers: byPreferredEmail, suggestByPreferredEmail
|
||||
CREATE INDEX accounts_byPreferredEmail
|
||||
ON accounts (preferred_email)
|
||||
#
|
||||
|
||||
-- covers: suggestByFullName
|
||||
CREATE INDEX accounts_byFullName
|
||||
ON accounts (full_name)
|
||||
#
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- AccountExternalIdAccess
|
||||
-- covers: byAccount
|
||||
CREATE INDEX account_external_ids_byAccount
|
||||
ON account_external_ids (account_id)
|
||||
#
|
||||
|
||||
-- covers: byEmailAddress, suggestByEmailAddress
|
||||
CREATE INDEX account_external_ids_byEmail
|
||||
ON account_external_ids (email_address)
|
||||
#
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- AccountGroupMemberAccess
|
||||
-- @PrimaryKey covers: byAccount
|
||||
CREATE INDEX account_group_members_byGroup
|
||||
ON account_group_members (group_id)
|
||||
#
|
||||
|
||||
-- *********************************************************************
|
||||
-- AccountGroupIncludeByUuidAccess
|
||||
-- @PrimaryKey covers: byGroup
|
||||
CREATE INDEX acc_gr_incl_by_uuid_byInclude
|
||||
ON account_group_by_id (include_uuid)
|
||||
#
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- AccountProjectWatchAccess
|
||||
-- @PrimaryKey covers: byAccount
|
||||
-- covers: byProject
|
||||
CREATE INDEX acc_project_watches_byProject
|
||||
ON account_project_watches (project_name)
|
||||
#
|
||||
|
||||
-- *********************************************************************
|
||||
-- AccountSshKeyAccess
|
||||
-- @PrimaryKey covers: byAccount, valid
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- ApprovalCategoryAccess
|
||||
-- too small to bother indexing
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- ApprovalCategoryValueAccess
|
||||
-- @PrimaryKey covers: byCategory
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- BranchAccess
|
||||
-- @PrimaryKey covers: byProject
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- ChangeAccess
|
||||
-- covers: submitted, allSubmitted
|
||||
CREATE INDEX changes_submitted
|
||||
ON changes (status, dest_project_name, dest_branch_name, last_updated_on)
|
||||
#
|
||||
|
||||
-- covers: byProjectOpenPrev, byProjectOpenNext
|
||||
CREATE INDEX changes_byProjectOpen
|
||||
ON changes (open, dest_project_name, sort_key)
|
||||
#
|
||||
|
||||
-- covers: byProject
|
||||
CREATE INDEX changes_byProject
|
||||
ON changes (dest_project_name)
|
||||
#
|
||||
|
||||
CREATE INDEX changes_key
|
||||
ON changes (change_key)
|
||||
#
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- ChangeMessageAccess
|
||||
-- @PrimaryKey covers: byChange
|
||||
|
||||
-- covers: byPatchSet
|
||||
CREATE INDEX change_messages_byPatchset
|
||||
ON change_messages (patchset_change_id, patchset_patch_set_id)
|
||||
#
|
||||
|
||||
-- *********************************************************************
|
||||
-- PatchLineCommentAccess
|
||||
-- @PrimaryKey covers: published, draft
|
||||
CREATE INDEX patch_comment_drafts
|
||||
ON patch_comments (status, author_id)
|
||||
#
|
||||
|
||||
-- *********************************************************************
|
||||
-- PatchSetAccess
|
||||
CREATE INDEX patch_sets_byRevision
|
||||
ON patch_sets (revision)
|
||||
#
|
||||
|
||||
-- *********************************************************************
|
||||
-- PatchSetAncestorAccess
|
||||
-- @PrimaryKey covers: ancestorsOf
|
||||
-- covers: descendantsOf
|
||||
CREATE INDEX patch_set_ancestors_desc
|
||||
ON patch_set_ancestors (ancestor_revision)
|
||||
#
|
||||
|
||||
|
||||
-- *********************************************************************
|
||||
-- StarredChangeAccess
|
||||
-- @PrimaryKey covers: byAccount
|
||||
|
||||
CREATE INDEX starred_changes_byChange
|
||||
ON starred_changes (change_id)
|
||||
#
|
||||
|
||||
-- *********************************************************************
|
||||
-- SubmoduleSubscriptionAccess
|
||||
|
||||
CREATE INDEX submod_subscr_ac_bySubscription
|
||||
ON submodule_subscriptions (submodule_project_name, submodule_branch_name)
|
||||
#
|
||||
|
@ -26,5 +26,12 @@ public class DataSourceModule extends AbstractModule {
|
||||
bind(DataSourceType.class).annotatedWith(Names.named("mysql")).to(MySql.class);
|
||||
bind(DataSourceType.class).annotatedWith(Names.named("oracle")).to(Oracle.class);
|
||||
bind(DataSourceType.class).annotatedWith(Names.named("postgresql")).to(PostgreSQL.class);
|
||||
/*
|
||||
* DatabaseMetaData.getDatabaseProductName() returns "sap db" for MaxDB.
|
||||
* For auto-detection of the DB type (com.google.gerrit.pgm.util.SiteProgram#getDbType)
|
||||
* we have to map "sap db" additionally to "maxdb", which is used for explicit configuration.
|
||||
*/
|
||||
bind(DataSourceType.class).annotatedWith(Names.named("maxdb")).to(MaxDb.class);
|
||||
bind(DataSourceType.class).annotatedWith(Names.named("sap db")).to(MaxDb.class);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed 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 com.google.gerrit.server.schema;
|
||||
|
||||
import static com.google.gerrit.server.schema.JdbcUtil.hostname;
|
||||
|
||||
import com.google.gerrit.server.config.ConfigSection;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
class MaxDb extends BaseDataSourceType {
|
||||
|
||||
private Config cfg;
|
||||
|
||||
@Inject
|
||||
public MaxDb(@GerritServerConfig final Config cfg) {
|
||||
super("com.sap.dbtech.jdbc.DriverSapDB");
|
||||
this.cfg = cfg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
final StringBuilder b = new StringBuilder();
|
||||
final ConfigSection dbs = new ConfigSection(cfg, "database");
|
||||
b.append("jdbc:sapdb://");
|
||||
b.append(hostname(dbs.optional("hostname")));
|
||||
b.append("/");
|
||||
b.append(dbs.required("database"));
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptRunner getIndexScript() throws IOException {
|
||||
return getScriptRunner("index_maxdb.sql");
|
||||
}
|
||||
}
|
6
lib/BUCK
6
lib/BUCK
@ -25,9 +25,9 @@ define_license(name = 'DO_NOT_DISTRIBUTE')
|
||||
|
||||
maven_jar(
|
||||
name = 'gwtorm',
|
||||
id = 'gwtorm:gwtorm:1.9',
|
||||
bin_sha1 = 'b03fbe78546788504a326dc6fbf94b93b6d8685e',
|
||||
src_sha1 = '1657bfdb8e9d3d5fa0ae63f38274c3469189ab53',
|
||||
id = 'gwtorm:gwtorm:1.10',
|
||||
bin_sha1 = '9ba8aa0c5df74a2fd635ec342c51a732e808543f',
|
||||
src_sha1 = '734b33f1b9561cbc8e445c6e18e73700dbe53bcc',
|
||||
license = 'Apache2.0',
|
||||
deps = [':protobuf'],
|
||||
repository = GERRIT,
|
||||
|
Loading…
Reference in New Issue
Block a user