After naively moving the classes, there were almost no incoming
references from the rest of the server packages into the new
server.receive package. This means with only a little more work, it was
possible to create a new java_library target containing just the srcs
in this new package. This is a modest step in the direction of breaking
up the giant //gerrit-server:server package, which will improve compile
times when making modifications that don't change the interface.
Change-Id: I449018a4933a999c688611142dc7ed9c18b4c828
It used to be that ConfigNotesMigration was the only kind of
NotesMigration in a real server, but it was always immutable, while
TestNotesMigration was the main kind of migration in acceptance tests,
which was mutable. However, now that we support modifying
ConfigNotesMigration at runtime as part of the online NoteDb migration
process, TestNotesMigration is no longer strictly necessary, and
continuing to support it is becoming more trouble than it's worth.
One major problem was that only TestNotesMigration was being populated
via NoteDbMode, and the NoteDbMode was not reflected in the
ConfigNotesMigration at all, so callers that were depending on
ConfigNotesMigration directly would not know about the NoteDb migration
state from the GERRIT_NOTEDB env var in tests.
We could have fixed this (and other) problems directly, but there is a
better solution: get rid of the test implementation entirely, and use
the same implementation of NotesMigration in tests as in a running
server.
The class hierarchy now contains only two classes: NotesMigration and
MutableNotesMigration. Most callers just care about inspecting the
state, so they can inject a NotesMigration. The few callers (migration,
tests) that care about mutating the state at runtime can inject/create
MutableNotesMigrations instead. As an implementation detail, the actual
NotesMigration instance continues to be mutable, containing a reference
to the Snapshot, but the base class does not contain any public methods
to mutate the state. We then ensure with Guice that there is only one
actual NotesMigration instance (the MutableNotesMigration), and callers
just may or may not have access to the mutation methods depending on
what they chose to inject.
Ensuring this gets set up correctly in tests requires a bit of tweaking.
* Since the NotesMigration is populated in the @UseLocalDisk case from
reading gerrit.config on disk, we need to prepopulate gerrit.config
with the right config values at startup time.
* Since MutableNotesMigration is not in the testutil package, it can't
have its own setFromEnv() method that depends on NoteDbMode.
Instead, construct MutableNotesMigrations from the test env by using
a static factory method in NoteDbMode.
Change-Id: If06db3d025cf3e3c9fe464989d5f38a22ce70b56
We're still on Gerrit version 2.x but when we move to 3.0 it
will not make sense to have the user named "gerrit2".
Update all the documentation to refer to "gerrit" instead.
Also change the Jetty configuration to use "gerrit" instead.
Change-Id: I43a343669ac936b0585ee15e07d15643f9c3d6eb
* stable-2.14:
Fix java.lang.ArrayIndexOutOfBoundsException when checking for parent
ProjectTagsScreen: Fix title of revision field for new tag
Fix cyclic dependency when using site_path from system_config table
Change-Id: I1f4ed09818885284b9686d38705a20cf21cfce23
The starting mode where site_path is not specified (as a system property)
and Gerrit first connects to the database using the ReviewDb JNDI
property from the servlet container was broken since I60f585f5ef due to
a cyclic dependency in Guice bindings.
Make sure to inject the non-wrapped SchemaFactory<ReviewDb> in the
SitePathFromSystemConfigProvider.
Change-Id: Ie283a5498e981642a82aac1fcb8b33b0c881fc84
Online reindex recalculates the status of all the changes
by invoking the Prolog rules associated.
That is good in general but breaks systematically when the
rules depend on plugins for their accurate evaluation.
Noteworthy example is the use of singleusergroup plugin in
conjunction with user-specific ACLs for labels.
Another even more severe example is the use of custom
Prolog predicates in rules.pl provided by the owners' plugin.
By swapping the order of registration of the Plugins module
and the Lucene Index module, the lifecycle listener will then
load first the plugins and only afterward activate the online
reindexer.
Bug: Issue 6472
Change-Id: I87da6ac632d08aa915a57a01435cfa415b7de2f9
The registration of PluginModule and PluginRestApiModule needs to be
decoupled because they are conceptually separate, even if one (PluginModule)
needs to happen before the other (PluginRestApiModule).
This is a pre-requisite for the next change I87da6ac6 where the PluginModule
registration needs to be moved around without necessarily having an impact
on the PluginRestApiModule.
Change-Id: I80fee34e5bda5afb480c8d103e6e83b8ae11c8eb
The API includes some new classes since 2.14 and we need to be able
to build snapshot artifacts to test plugins that use the new classes.
Change-Id: Ifad31b93e5b5068c0d6952582f6882edc252e227
FileInputStream and FileOutputStream rely on finalize() method to ensure
resources are closed. This implies they are added to the finalizer queue
which causes additional work for the JVM GC process.
This is an open bug on the OpenJDK [1] and the recommended workaround is
to use the Files.newInputStream and Files.newOutputStream static methods
instead.
[1] https://bugs.openjdk.java.net/browse/JDK-8080225
Change-Id: I3cef6fcf198dde2be7cd15bded8d2fa247177654
Move the binding out of GerritGlobalModule so it's part of the daemons,
making it easier to swap to a different PermissionBackend.
Expose DefaultPermissionBackend class as public so another backend
could wrap and delegate to DefaultPermissionBackend by accepting it
as an argument to its constructor.
Change-Id: I01f10d8a65d8942e73354bcf055c26b17d2606f9
* stable-2.14:
Move systemctl files to /init/ rather than /systemd/
SitePathInitializer: Fix destination file name for gerrit.socket
Clarify documentation for accountPatchReviewDb.url
Add the new gerrit systemctl file to init
Remove unneeded output in MigrateAccountPatchReviewDb
ES: Implement online reindex for ElasticSearch
JdbcAccountPatchReviewStore: Fix copyright year
Fix documentation nits in pgm-MigrateAccountPatchReviewDb.txt
Support Jdbc implementation of AccountPatchReviewStore
ES: Temporarily disable server discovery
Change-Id: I1034869bc6146db929f6242610c9eb13a7b092f7
Provide in gerrit core support for alternative database backends
for AccountPatchReview store.
H2 was used for storing AccountPatchReview. This can become
problematic in large installation since embedded H2 cannot execute
concurrent requests even to the same database. The options related to
multi-thread in H2 are:
- MULTI_THREADED: a long running query blocks the ones in other
threads [1].
- MVCC: This is not production-ready yet, since it is not fully
tested [2].
AccountPatchReviewStore is an extension and a plugin could
implement a jdbc store but this would result in duplicated code
with core H2 implementation. Since core H2 implementation was
almost already compliant to jdbc standard, it's easy to make
jdbc url configurable in gerrit config and make the core support
other database than H2.
One could extend the H2 implementation in plugin, however the
changes on the supper class could lead to breaking plugin
implementation.
[1] http://www.h2database.com/html/features.html#multiple_connections
[2] http://www.h2database.com/html/advanced.html#mvcc
Change-Id: Ie61ac63a72cab71bd907886a794541cb3dea291e
* stable-2.14:
Add new maintainers to developers section in pom.xml files
Update Version to 2.14-rc0
Change-Id: Ib620c5f49ec5dee1a838c082f74b785689edba71
* stable-2.14:
PolyGerrit: Bug fix for iOS 10.3 and mac 10.12.4
Replace AbstractFileKeyPairProvider with FileKeyPairProvider in log4j config
Change-Id: Ic3c681c37ee5521e43008314324da4d6259b8d90
The AbstractFileKeyPairProvider class was replaced with FileKeyPairProvider
in the upgrade from sshd 1.2 to 1.4.
Change-Id: I711582ea01235849f40991fa7aefd13673aa2277
* stable-2.13:
Prevent circular module dependency when running in external container
Update Documentation of Auto Site Initialization
Change-Id: Ibcbaf7e7b5af58dca5c9b32d068acb81d1fd9781
Commit 220a3f5 introduced circular dependency between the database
module and NotesMigration (impl. class ConfigNotesMigration).
Having the site path being stored in the database was broken by above
change. The class Daemon solves this by explicitly setting the site
path and adds a SitePath module before starting everything.
This patch makes it possible again to run the gerrit war in an external
Servlet container, but you need to set the System property
"-Dgerrit.site_path=/path/to/gerrit" to make it work.
The site path stored in the database became practically obsolete with the
NotesMigration change mentioned above.
Change-Id: Id735fbf928dda186e659792c84d4e675c893a29a
Reformatting the code with google-java-format tool in change Id5f3c6de9
resulted in wrapped lines being unwrapped to the new 100 columns limit.
In cases where the wrapped line was wrapped on a string concatenation,
the resulting long line now includes redundant concatenations. See the
upstream issue [1] for an example of this.
Squash the redundant concatenations with:
git ls-files | grep java$ | xargs sed -i '' 's/" + "//g'
(note: this also resulted in a couple of unwanted changes; those are
manually undone.)
[1] https://github.com/google/google-java-format/issues/122
Change-Id: I7348413ae460c8c7a0b0c72dab0a1ae7275a2ec3
Having a standard tool for formatting saves reviewers' valuable time.
google-java-format is Google's standard formatter and is somewhat
inspired by gofmt[1]. This commit formats everything using
google-java-format version 1.2.
The downside of this one-off formatting is breaking blame. This can be
somewhat hacked around with a tool like git-hyper-blame[2], but it's
definitely not optimal until/unless this kind of feature makes its way
to git core.
Not in this change:
* Tool support, e.g. Eclipse. The command must be run manually [3].
* Documentation of best practice, e.g. new 100-column default.
[1] https://talks.golang.org/2015/gofmt-en.slide#3
[2] https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html
[3] git ls-files | grep java$ | xargs google-java-format -i
Change-Id: Id5f3c6de95ce0b68b41f0a478b5c99a93675aaa3
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
This allows to do checks on Gerrit startup and abort the Gerrit startup
if issues are found. E.g. this allows us to do validation on the Gerrit
config, which is needed by a follow-up change.
The startup checks are done after all lifecycle listeners have been
invoked so that logging is already available and the reason for a
failing startup can be written to the error log.
All implementations of StartupCheck should be bound in
StartupChecks.Module.
Change-Id: I941dad2c926130a1f9c5a1a363f7e1eff0dab304
Signed-off-by: Edwin Kempin <ekempin@google.com>
SSH command registration was extended so that command gets registered
only in case when plugin is configured in gerrit.config.
Change-Id: Iffaf00775bdf1242e1fbe1dea15e5ce0bf912079
Signed-off-by: Jacek Centkowski <geminica.programs@gmail.com>
Reformat the Bazel build files with the buildifier tool [1].
The style is different for Bazel files. Most notably, indentation level
is 4 spaces instead of 2, and " is used instead of '.
[1] https://github.com/bazelbuild/buildifier
Change-Id: I95c0c6f11b6d76572797853b4ebb5cee5ebd3c98
Gerrit already has "pluggable" features that need to be installed
at the early stages of the bootstrap phase and cannot be "unplugged"
as plugins do.
Attendees at the recent hackathon in Mountain View decided to
call this new entities "LibModules", and configure them in the
gerrit.config as follows:
[gerrit]
installModule = com.googlesource.gerrit.libmodule.MyModule
installModule = com.example.abc.OurSpecialSauceModule
Change-Id: Id8bf1a2e88b14c8e9125f20cb10a041d47799100