41 Commits

Author SHA1 Message Date
David Pursehouse
41abb376ca Enable and fix Eclipse warnings about redundant type arguments
Since Java 7 it is possible to replace the type arguments required to
invoke the constructor of a generic class with an empty set of type
parameters (<>) as long as the compiler can infer the type arguments
from the context [1].

Enable the Eclipse warning about redundant type arguments, and remove
the ones it warns about.

[1] http://goo.gl/SG21kM

Change-Id: I422882949a6a6a57391580d881f73120b2843a0e
2014-10-31 08:27:01 +00:00
David Pursehouse
75ad80aa57 Remove unnecessary suppression of cast warning in H2CacheFactory
Change-Id: I1d2ef58029d9c439aa0cf0f195d66a4ed63ff40e
2014-10-30 10:06:40 +09:00
David Ostrovsky
8dc720ed9b Move TimeUtil from gerrit-server to gerrit-common
Change-Id: Ib2cfcfd4974ab04e733007e5835fc1364cc36ee9
2014-10-06 07:53:44 -07:00
Saša Živkov
1c48a7ee1c Revert "Use javax.inject.Inject instead of com.google.inject.Inject"
This reverts commit 5db3bba3e2d85662bacedc5d2f215fff7d8d2805.

I was too fast to submit 5db3bba. Besides forgetting to submit the
referenced changes in some submodules some people reported issues
with the interception of the javax.inject.Inject in some JEE containers.

Change-Id: I931ad329d2e7be6f6ce804b8395489a021c8240b
2014-09-30 10:53:50 +02:00
Dave Borowitz
5db3bba3e2 Use javax.inject.Inject instead of com.google.inject.Inject
The Guice team is discouraging use of its specific annotation where
possible, to increase JSR330 compliance.

Leave optional injection alone for now, which needs to be manually
replaced with OptionalBinder.

Change-Id: I4f53a518ba6f36fd67af12f3540dc44cbad07ff8
2014-09-29 16:36:18 -07:00
Saša Živkov
98adfd5c53 Honor expireAfterWrite in the H2CacheImpl
The H2CacheImpl didn't honor the expireAfterWrite. This had an effect
that persisted entries never expired. For example, the web_sessions
cache entries didn't expire after their maxAge was reached.

Change-Id: I3a7c754ee05fe9ac92d96652db4b862bb597eba1
Signed-off-by: Saša Živkov <sasa.zivkov@sap.com>
Signed-off-by: Adrian Görler <adrian.goerler@sap.com>
2014-09-15 16:37:53 +02:00
Edwin Kempin
42c9cf61c8 Add REST endpoint to list caches
GET /config/server/caches/ lists the server caches. Caches defined by
plugins are included.

The implementation of the SSH show-caches was adapted so that it uses
the new REST endpoint to get the information about the caches. This
avoids code duplication.

For disk caches a new interface was introduced in gerrit-server. This
is done because the list caches REST endpoint needs extra information
for disk caches which can only be provided by the disk cache, aka
H2CacheImpl. H2CacheImpl is defined in gerrit-cache-h2, but
gerrit-server doesn't have a dependency on it and hence can't use
instanceof to check whether a cache is a disk cache. Adding this
dependency is not wanted and also not possible (because
gerrit-cache-h2 already depends on gerrit-server and we can't have
cycles in the dependencies).

Change-Id: I21bf6e114310f98051a0a8db01012511f58d4add
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2014-05-28 09:29:12 +02:00
David Ostrovsky
e73ae61339 Apply "type inference for generic instance creation" Java 7 feature
Change-Id: Ia14802c903ca67b9d94dc6038d70b0e9644bc621
2014-04-26 15:27:57 +02:00
Saša Živkov
218c6b69c2 Allow creation of persistent caches after server is started
2e1cb2b8495761a7e9abc09ebca24ca6bbf2afbe switches from Ehcache to Guava
for providing caching in Gerrit and claims that one of the advantages of
using Guava is that it enables caches to be build at any time, rather
than only at server startup. Therefore, I guess it is OK to remove the
precondition check which prevents creation of caches once the server was
started.

This enables plugins to create own persistent caches when they are
installed.

Change-Id: I28b1a140c58f9967e6d1dacd61ddd021b48c8ad5
2014-03-10 17:22:46 +01:00
David Pursehouse
85c458b4d8 Merge "Remove unused @SuppressWarnings" 2013-11-29 08:08:53 +00:00
Shawn Pearce
74966d5b04 Remove unused @SuppressWarnings
Eclipse Kepler says these are not necessary.

Change-Id: Ie7af85e512532b084a1a13df37792ffec11680fc
2013-11-29 09:03:35 +01:00
Shawn Pearce
72fb6cc514 Remove unused .gitignore
These were necessary only for the Maven based build.

Change-Id: Ie26669e6ccae60a52d2db1b8ad362e2fa88a26f2
2013-11-28 22:56:51 -08:00
David Ostrovsky
c53fd3ae49 Delete eclipse left-over files from the Maven poop era
Change-Id: Ie3a75e8c6a2d274cd39e362259ab20cff474eb8d
2013-11-28 22:55:09 -08:00
alex.ryazantsev
bbf93f85cf Remove unnecessary local variables
Change-Id: I20ee3f7258d7e98b9c57b49c21b1e2d1582f626f
2013-11-19 13:56:25 -08:00
Dave Borowitz
ec6fca88a5 Make LifecycleModule inherit from FactoryModule
Cut down on a bunch of one-offs of install(new *Module() {...}) by
choosing a more appropriate base module class. This doesn't solve all
such cases, for example RpcServletModule must still inherit from
ServletModule, but it does clean up some code. (And who knows, fewer
modules may even mean faster startup time.)

Change-Id: Ie1aed05d0a64f7f11b121c9a637bb30d80e9a595
2013-11-13 16:14:00 +00:00
Shawn Pearce
f5016f461b Merge branch 'stable-2.7' into stable-2.8
* stable-2.7:
  Bump JSch to 1.5.0 to fix Java7 compatibility
  Extend AddBranchResult with toString method implementation
  Get rid of JdbcSQLException while numbers are read from cache

Conflicts:
	gerrit-common/src/main/java/com/google/gerrit/common/data/AddBranchResult.java
	pom.xml

Change-Id: Ic3bae80a40bfa2d8e8eee598bcdbd771b99cbeda
2013-11-05 11:15:47 -08:00
Shawn Pearce
5d1ce02e9d Merge branch 'stable-2.6' into stable-2.7
* stable-2.6:
  Bump JSch to 1.5.0 to fix Java7 compatibility
  Extend AddBranchResult with toString method implementation
  Get rid of JdbcSQLException while numbers are read from cache
2013-11-05 11:14:11 -08:00
Jacek Centkowski
b294b033bb Get rid of JdbcSQLException while numbers are read from cache
Exception org.h2.jdbc.JdbcSQLException: Hexadecimal string with odd
number of characters: "0" is thrown when number with value 0 or string
with value "0" is stored in H2Cache and read is performed.
The fix modifies implementation so that Java de-serialization is
performed even for built-in (e.g. Integer) types.

Change-Id: I953487cb75b3712e8825a74613977425873507a1
Signed-off-by: Jacek Centkowski <geminica.programs@gmail.com>
2013-10-30 07:21:16 -07:00
Dave Borowitz
1d69c2e8ce Add TimeUtil.nowTs() to create a new Timestamp
Change-Id: I5b2457703a5812c99cd71dc2ad87e45ae5d665e2
2013-10-16 10:10:55 -07:00
Dave Borowitz
46b1ac8f07 Use DateTimeUtils.currentTimeMillis() to get current time
This method from joda-time supports replacing the system time provider
with a custom provider for tests. Since it is verbose, and we expect
more related methods, put it in the more succinct TimeUtil.nowMs().

This commit covers the trivial cases in the server side; client-side
code still uses System.currentTimeMillis().

Change-Id: I6c56e8c5bbb0cf7b0271e431d1ebdb532967b9e8
2013-10-16 10:10:55 -07:00
David Pursehouse
99776b87c8 Replace Funnels.stringFunnel with Funnels.unencodedCharsFunnel
In Guava 15.0 the `stringFunnel()` method is deprecated in favor
of `unencodedCharsFunnel()`.

Change-Id: Ie99e3305f5ec497a36033142283dd5994803a254
2013-10-01 12:27:18 +09:00
Dave Borowitz
01cea13727 Set version to 2.7
Change-Id: I49a7fc97fd6d4f199c25774faa50ec4a826ae64a
2013-09-18 13:05:11 -07:00
Edwin Kempin
dcab15ebed Use CacheBuilder returned from CacheBuilder.removalListener(...)
The JavaDoc of CacheBuilder.removalListener(...) states that after
invoking this method this CacheBuilder should not be used anymore but
only the returned CacheBuilder.

Change-Id: Ibe7cb90624ca29e3492dbc84d029758bed0055c3
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2013-08-22 15:37:02 +02:00
Shawn Pearce
f252f5348e Gerrit 2.6
Change-Id: I7b6704181bae0953d7de021611ff8e8a0165b93f
2013-06-21 09:51:01 -07:00
David Ostrovsky
dcee57212f Delete Maven based build
The Maven build does not work since the introduction of CodeMirror.
Remove the build until to prevent people from trying to use a broken
build process.  If buck is rejected this commit will be reverted, and
we will attempt to fix the Maven build to include CodeMirror.  If buck
is accepted, we just saved time by avoiding a messy Maven change.

Change-Id: I147d8d1741d52f59de1d2ddce8e5e82583990c14
2013-05-21 20:28:56 -07:00
Shawn Pearce
bd5629718f Update buck build for strict dependencies
java_library() targets must now list every dependency they need for
an import. This permits buck to run more targets in parallel as it
has a better view of the dependency graph, and opens the door for
buck to make even more optimizations in the future.

Change-Id: I132bf47a725e44ba5950ba6ca76bfa72c3876906
2013-05-16 01:14:27 +00:00
Shawn Pearce
fd6bb9f6a5 Build with Buck
Implement a new build system using Buck[1], Facebook's
open source clone of Google's internal build system.

  Pros:
  - Concise build language
  - Test and build output is concise
  - Test failures and stack traces show on terminal
  - Reliable incrementals; clean is unnecessary
  - Extensible with simple blocks of Python
  - Fast
      buck: clean: 0.452s, full 1m21.083s [*], no-op:  7.145s,
      mvn:  clean: 4.596s, full 2m53.776s,     no-op: 59.108s,

      [*] full build includes downloading all dependencies,
          time can vary due to remote server performance.

  Cons:
  - No Windows support
  - No native Maven Central support (added by macros)
  - No native GWT, Prolog, or WAR support (added by macros)
  - Bootstrap of buck requires Ant

Getting started:

  git clone https://gerrit.googlesource.com/buck
  cd buck
  ant

  Mac OS X:
    PATH="`pwd`/bin:/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands:$PATH"

  Linux:
    PATH="`pwd`/bin:$PATH"

Importing into Eclipse:

  $ time buck build :eclipse
  0m48.949s

  Import existing project from `pwd`
  Import 'gerrit' (do not import other Maven based projects)
  Expand 'gerrit'
  Right click 'buck-out' > Properties
  Under Attributes check 'Derived'

  If the code doesn't currently compile but an updated classpath
  is needed, refresh the configs and obtain missing JARs:

  $ buck build :eclipse_project :download

Running JUnit tests:

  $ time buck test --all -e slow  # skip slow tests
  0m19.320s

  $ time buck test --all          # includes acceptance tests
  5m17.517s

Building WAR:

  $ buck build :gerrit
  $ java -jar buck-out/gen/gerrit.war

Building release:

  $ buck test --all && buck build :api :release
  $ java -jar buck-out/gen/release.war
  $ ls -lh buck-out/gen/{extension,plugin}-api.jar

Downloading dependencies:

  Dependencies are normally downloaded automatically, but Buck can
  inspect its graph and download missing dependencies so future
  compiles can run without the network:

  $ buck build :download

[1] http://facebook.github.io/buck/

Change-Id: I40853b108bd8e153cefa0896a5280a9a5ff81655
2013-05-09 13:40:36 +00:00
Shawn Pearce
9240c299f0 Begin 2.8
Change-Id: Ie0bc733853be435fba147dd64ef8cbc5a0027ee0
2013-05-06 19:39:10 -07:00
Shawn Pearce
d47ca8a66d Start 2.7 development
Change-Id: I08dc590bb1f62af67d88eb11313d5d4cfe2423c4
2013-03-21 12:12:47 -07:00
Edwin Kempin
2820055fd8 Fix various warnings
Remove unused imports, unused fields and variables, unused private
methods and unnecessary @SuppressWarnings.

Change-Id: Iff3dbd9e2669fcaa7cb42c1accfddfb2ba82b6e0
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2012-10-18 13:38:51 +02:00
Shawn O. Pearce
7dd18f5f2c Merge branch 'stable-2.5'
* stable-2.5:
  Fix order of top-level menus
  Ensure that ObjectOutputStream in H2CacheImpl is closed
  Flush persistent H2 cache if the existing entries are incompatible
  Fix plugin loading when running as hosted WAR or GWT DevMode.
  ChangeMessageAccess: Add index for byPathSet method.
  File indentation is sometimes wrong in Side-By-Side
  Move the Groups and Plugins menu items to the top level.
  Call inserter.flush() when creating code review notes
  Add ssh command "test-submit-rule"
  Split up canSubmit()
  Add submit records to query output.

Conflicts:
	Documentation/json.txt
	gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java
	gerrit-server/src/main/java/com/google/gerrit/server/project/ChangeControl.java

Change-Id: I6f9d44cfbd7060d65c8eb8a399d089a88f9bc697
2012-10-16 12:13:32 -07:00
Shawn Pearce
b20787764a Merge "Flush persistent H2 cache if the existing entries are incompatible" into stable-2.5 2012-10-16 10:17:42 -07:00
Edwin Kempin
18c8fa8922 Ensure that ObjectOutputStream in H2CacheImpl is closed
Change-Id: I8a999a6203254deab2e55e242a660e23616d36c2
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2012-10-16 16:54:25 +02:00
Edwin Kempin
3f461de64e Flush persistent H2 cache if the existing entries are incompatible
Some caches (e.g. 'diff_intraline') are peristent so that the entries
survive a Gerrit restart (e.g. because the entries are expensive to
compute). To persist the cache entries Java serialization is used. If
now a class for a cache entry is changed and its serialVersionUID is
updated, already peristent cache entries cannot be deserialized anymore
since their class is incompatible with the new cache entry class.

Flush the cache if incompatible cache entries are detected.

E.g. commit 2424a8a9d595c87106db51da5867ed417eb8a2f5 changed a cache
entry class and as result the existing entries of the 'diff_intraline'
cache could not be loaded anymore, which caused an exception on each
Gerrit startup and when trying to access one of these cached entries.
To get rid of these exeptions the Gerrit administrator had to manually
flush the cache.

Change-Id: Ia158855d983d51335ae2a4df2b73d6c14fc612f0
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2012-10-16 16:46:14 +02:00
Edwin Kempin
20f99685d9 Update versions in pom's to start Gerrit 2.6 development
Change-Id: I4fb8cb41250c5b640a8d9e47caf97dc4670ff428
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2012-08-22 14:09:52 +02:00
Chad Horohoe
6d982fc28f Cleaning up serialVersionUIDs
Change-Id: If7b8ed2d5f880734257230b8cbf4a9c7ebce9a96
2012-08-16 13:22:37 -04:00
Edwin Kempin
149c79d933 Remove double ';' at line ending
My Eclipse doesn't like it and claims it's a syntax error.

Change-Id: Ib6a9a2e8e47a1bfc0ca11b382e732be15e2ae176
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
2012-08-06 14:30:23 +02:00
Keunhong Park
c3a31c2595 Add support for binding CacheRemovalListener
This can be used to dynamically bind removal listeners for use in
multi-master support.

Change-Id: I9c58740c54c89e5bd75accc64f03f1fdddc8d581
2012-08-02 12:58:15 -06:00
Sasa Zivkov
90119f8256 Remove timestamp from all org.eclipse.core.resources.prefs files.
Eclipse overwrites these files when we import projects using m2e.
Eclipse 3 writes a timestamp at the top of these files making the Git
working tree dirty.  Eclipse 4 (Juno) still overwrites these files but
doesn't write the timestamp.  This should help keeping the working tree
clean.  However, since the timestamp is currently present in these
files, Eclispe 4 would still make them dirty by overwriting and
effectively removing the timestamp.

This change removes the timestamp from these files. This help those
using Eclipse 4 and doesn't make it worse for those still using Eclispe
3.

Change-Id: Ic23299a12ac80f7294bcc602c8565889069a0d10
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2012-07-04 14:06:09 +02:00
Shawn O. Pearce
0b549fb3e2 Record stats for all caches
This is disabled by default in Guava, but we report in show-caches
average loading time. To ensure it isn't always 0, record stats.

Change-Id: I9861b0b20463c8893933d41788139a4c374caaab
2012-05-25 09:03:54 -07:00
Shawn O. Pearce
2e1cb2b849 Back in-memory caches with Guava, disk caches with H2
Instead of using Ehcache for in-memory caches, use Guava. The Guava
cache code has been more completely tested by Google in high load
production environments, and it tends to have fewer bugs. It enables
caches to be built at any time, rather than only at server startup.

By creating a Guava cache as soon as it is declared, rather than
during the LifecycleListener.start() for the CachePool, we can promise
any downstream consumer of the cache that the cache is ready to
execute requests the moment it is supplied by Guice. This fixes a
startup ordering problem in the GroupCache and the ProjectCache, where
code wants to use one of these caches during startup to resolve a
group or project by name.

Tracking the Gauva backend caches with a DynamicMap makes it possible
for plugins to define their own in-memory caches using CacheModule's
cache() function to declare the cache. It allows the core server to
make the cache available to administrators over SSH with the gerrit
show-caches and gerrit flush-caches commands.

Persistent caches store in a private H2 database per cache, with a
simple one-table schema that stores each entry in a table row as a
pair of serialized objects (key and value). Database reads are gated
by a BloomFilter, to reduce the number of calls made to H2 during
cache misses. In theory less than 3% of cache misses will reach H2 and
find nothing. Stores happen on a background thread quickly after the
put is made to the cache, reducing the risk that a diff or web_session
record is lost during an ungraceful shutdown.

Cache databases are capped around 128M worth of stored data by running
a prune cycle each day at 1 AM local server time. Records are removed
from the database by ordering on the last access time, where last
accessed is the last time the record was moved from disk to memory.

Change-Id: Ia82d056796b5af9bcb1f219fe06d905c9c0fbc84
2012-05-24 18:09:46 -07:00