I'm currently researching the resilience4j library and for some reason the following code doesn't work as expected:
#Test
public void testRateLimiterProjectReactor()
{
// The configuration below will allow 2 requests per second and a "timeout" of 2 seconds.
RateLimiterConfig config = RateLimiterConfig.custom()
.limitForPeriod(2)
.limitRefreshPeriod(Duration.ofSeconds(1))
.timeoutDuration(Duration.ofSeconds(2))
.build();
// Step 2.
// Create a RateLimiter and use it.
RateLimiterRegistry registry = RateLimiterRegistry.of(config);
RateLimiter rateLimiter = registry.rateLimiter("myReactorServiceNameLimiter");
// Step 3.
Flux<Integer> flux = Flux.from(Flux.range(0, 10))
.transformDeferred(RateLimiterOperator.of(rateLimiter))
.log()
;
StepVerifier.create(flux)
.expectNextCount(10)
.expectComplete()
.verify()
;
}
According to the official examples here and here this should be limiting the request() to 2 elements per second. However, the logs show it's fetching all of the elements immediately:
15:08:24.587 [main] DEBUG reactor.util.Loggers - Using Slf4j logging framework
15:08:24.619 [main] INFO reactor.Flux.Defer.1 - onSubscribe(RateLimiterSubscriber)
15:08:24.624 [main] INFO reactor.Flux.Defer.1 - request(unbounded)
15:08:24.626 [main] INFO reactor.Flux.Defer.1 - onNext(0)
15:08:24.626 [main] INFO reactor.Flux.Defer.1 - onNext(1)
15:08:24.626 [main] INFO reactor.Flux.Defer.1 - onNext(2)
15:08:24.626 [main] INFO reactor.Flux.Defer.1 - onNext(3)
15:08:24.626 [main] INFO reactor.Flux.Defer.1 - onNext(4)
15:08:24.626 [main] INFO reactor.Flux.Defer.1 - onNext(5)
15:08:24.626 [main] INFO reactor.Flux.Defer.1 - onNext(6)
15:08:24.626 [main] INFO reactor.Flux.Defer.1 - onNext(7)
15:08:24.626 [main] INFO reactor.Flux.Defer.1 - onNext(8)
15:08:24.626 [main] INFO reactor.Flux.Defer.1 - onNext(9)
15:08:24.626 [main] INFO reactor.Flux.Defer.1 - onComplete()
I don't see what's wrong?
As already answered in comments above RateLimiter tracks the number of subscriptions, not elements. To achieve rate limiting on elements you can use limitRate (and buffer + delayElements).
For example,
Flux.range(1, 100)
.delayElements(Duration.ofMillis(100)) // to imitate a publisher that produces elements at a certain rate
.log()
.limitRate(10) // used to requests up to 10 elements from the publisher
.buffer(10) // groups integers by 10 elements
.delayElements(Duration.ofSeconds(2)) // emits a group of ints every 2 sec
.subscribe(System.out::println);
This setup was already running and working fine. But something happened: maybe some package got updated, some file corrupted or a network change broke it.
The command bin/gerrit.sh start returns Starting Gerrit Code Review: FAILED.
logs/error_log:
[2018-11-28 11:49:01,135] [main] WARN com.google.gerrit.sshd.SshDaemon : Disabling cipher aes192-ctr: Unable to initialize cipher BaseCipher[AES,16,24,AES/CTR/NoPadding]
[2018-11-28 11:49:01,135] [main] WARN com.google.gerrit.sshd.SshDaemon : Disabling cipher aes256-ctr: Unable to initialize cipher BaseCipher[AES,16,32,AES/CTR/NoPadding]
[2018-11-28 11:49:01,138] [main] WARN com.google.gerrit.sshd.SshDaemon : Disabling cipher arcfour256: Illegal key size or default parameters; try installing unlimited cryptography extension
[2018-11-28 11:49:01,145] [main] WARN com.google.gerrit.sshd.SshDaemon : Disabling cipher aes192-cbc: Unable to initialize cipher BaseCipher[AES,16,24,AES/CBC/NoPadding]
[2018-11-28 11:49:01,145] [main] WARN com.google.gerrit.sshd.SshDaemon : Disabling cipher aes256-cbc: Unable to initialize cipher BaseCipher[AES,16,32,AES/CBC/NoPadding]
[2018-11-28 11:49:01,214] [main] WARN com.google.gerrit.sshd.SshDaemon : Cannot format SSHD host key [EdDSA]: invalid key type
[2018-11-28 11:49:01,227] [main] WARN com.google.gerrit.server.config.GitwebCgiConfig : gitweb not installed (no /usr/lib/cgi-bin/gitweb.cgi found)
[2018-11-28 11:49:02,025] [main] INFO org.eclipse.jetty.util.log : Logging initialized #8689ms
[2018-11-28 11:49:02,102] [main] INFO com.google.gerrit.server.git.LocalDiskRepositoryManager : Defaulting core.streamFileThreshold to 332m
[2018-11-28 11:49:02,121] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Removing stale plugin file: plugin_hooks_181128_1116_5514078957117773811.jar
[2018-11-28 11:49:02,121] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Removing stale plugin file: plugin_events-log_181128_1116_8975419966674917654.jar
[2018-11-28 11:49:02,122] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Removing stale plugin file: plugin_download-commands_181128_1116_7149912149640119287.jar
[2018-11-28 11:49:02,122] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Removing stale plugin file: plugin_replication_181128_1116_3000551844744811569.jar
[2018-11-28 11:49:02,122] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Removing stale plugin file: plugin_commit-message-length-validator_181128_1116_2800985912637941647.jar
[2018-11-28 11:49:02,122] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Removing stale plugin file: plugin_reviewnotes_181128_1116_1435979824854811361.jar
[2018-11-28 11:49:02,122] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Removing stale plugin file: plugin_singleusergroup_181128_1116_4944938881709642049.jar
[2018-11-28 11:49:02,122] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loading plugins from /home/gerrit/gerrit_testsite/plugins
[2018-11-28 11:49:02,199] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin commit-message-length-validator, version v2.14.2
[2018-11-28 11:49:02,250] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin download-commands, version v2.14.2
[2018-11-28 11:49:02,484] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin events-log, version e271462
[2018-11-28 11:49:02,550] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin hooks, version v2.14.2
[2018-11-28 11:49:02,638] [main] WARN com.googlesource.gerrit.plugins.replication.ReplicationFileBasedConfig : Config file /home/gerrit/gerrit_testsite/etc/replication.config does not exist; not replicating
[2018-11-28 11:49:02,641] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin replication, version v2.14.2
[2018-11-28 11:49:02,697] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin reviewnotes, version v2.14.2
[2018-11-28 11:49:02,736] [main] INFO com.google.gerrit.server.plugins.PluginLoader : Loaded plugin singleusergroup, version v2.14.2
[2018-11-28 11:49:02,975] [main] INFO com.google.gerrit.server.change.ChangeCleanupRunner : Ignoring missing changeCleanup schedule configuration
[2018-11-28 11:49:02,998] [main] INFO com.google.gerrit.sshd.SshDaemon : Started Gerrit SSHD-CORE-1.4.0 on *:29419
[2018-11-28 11:49:03,002] [main] INFO org.eclipse.jetty.server.Server : jetty-9.3.17.v20170317
[2018-11-28 11:49:03,787] [main] INFO org.eclipse.jetty.server.handler.ContextHandler : Started o.e.j.s.ServletContextHandler#384cd83a{/r,null,AVAILABLE}
[2018-11-28 11:49:43,834] [main] ERROR com.google.gerrit.pgm.Daemon : Unable to start daemon
java.lang.IllegalStateException: Cannot start HTTP daemon
at com.google.gerrit.pgm.http.jetty.JettyServer$Lifecycle.start(JettyServer.java:106)
at com.google.gerrit.lifecycle.LifecycleManager.start(LifecycleManager.java:92)
at com.google.gerrit.pgm.Daemon.start(Daemon.java:323)
at com.google.gerrit.pgm.Daemon.run(Daemon.java:232)
at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:204)
at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:108)
at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:63)
at Main.main(Main.java:24)
Caused by: java.net.SocketException: Unresolved address
at sun.nio.ch.Net.translateToSocketException(Net.java:131)
at sun.nio.ch.Net.translateException(Net.java:157)
at sun.nio.ch.Net.translateException(Net.java:163)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:76)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:317)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:401)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.google.gerrit.pgm.http.jetty.JettyServer$Lifecycle.start(JettyServer.java:92)
... 12 more
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Net.java:101)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:218)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
... 19 more
The configuration file is listed below, we use a LDAP server to authenticate:
[gerrit]
basePath = git
serverId = c3094920-33f3-4219-82cf-0181f4f0c7e7
canonicalWebUrl = http://oururl/r/
[database]
type = h2
database = /home/gerrit/gerrit_testsite/db/ReviewDB
[index]
type = LUCENE
[auth]
type = ldap
gitBasicAuthPolicy = LDAP
[ldap]
server = ldap://ldapserver
accountBase = OU=Usuários Rede,DC=company,DC=com,DC=br
groupBase = OU=Grupos,DC=company,DC=com,DC=br
referral = follow
accountPattern = (mailNickname=${username})
groupPattern = (memberOf=${cn})
accountFullName = cn
accountEmailAddress = mail
localUsernameToLowerCase = true
accountSshUserName = cn
username = ldapread#company.com.br
password = pass
[receive]
enableSignedPush = false
[sendemail]
smtpServer = mail.company.com.br
smtpServerPort = 587
smtpEncryption = tls
sslVerify = false
allowedDomain = company.com.br
smtpUser = gerrit#company.com.br
smtpPass = pass
[container]
user = gerrit
javaHome = /usr/lib/jvm/java-8-oracle/jre
[sshd]
listenAddress = *:29419
[httpd]
listenUrl = http://engenharia.company.com.br:8888/r/
[cache]
directory = cache
[download]
command = checkout
command = cherry_pick
command = format_patch
command = pull
scheme = ssh
[capability]
accessDatabase = group Administrators
[plugins]
allowRemoteAdmin = true
[plugin "events-log"]
storeUrl = jdbc:h2:/tmp/db
What can I do to debug the issue? (I haven't done the Gerrit setup and installation.)
It wasn't related to Gerrit.
A network change disabled Gerrit. After changing the DNS server and gateway of the Gerrit machine, everything is working again.
I have an ontology that imports another ontology (both are stored in the same folder on my machine, created using Protege & saved as RDF/XML). When I create the ontology model in my java application through Jena, I get the following
0 [main] DEBUG org.apache.jena.riot.system.stream.JenaIOEnvironment - Failed to find configuration: location-mapping.ttl;location-mapping.rdf;location-mapping.n3;etc/location-mapping.rdf;etc/location-mapping.n3;etc/location-mapping.ttl
297 [main] DEBUG com.hp.hpl.jena.util.FileManager - Add location: LocatorFile
300 [main] DEBUG com.hp.hpl.jena.util.FileManager - Add location: ClassLoaderLocator
301 [main] DEBUG com.hp.hpl.jena.util.LocationMapper - Failed to find configuration: file:location-mapping.rdf;file:location-mapping.n3;file:location-mapping.ttl;file:etc/location-mapping.rdf;file:etc/location-mapping.n3;file:etc/location-mapping.ttl
301 [main] DEBUG com.hp.hpl.jena.util.FileManager - Add location: LocatorFile
301 [main] DEBUG com.hp.hpl.jena.util.FileManager - Add location: LocatorURL
301 [main] DEBUG com.hp.hpl.jena.util.FileManager - Add location: ClassLoaderLocator
301 [main] DEBUG com.hp.hpl.jena.util.FileManager - Add location: LocatorFile
301 [main] DEBUG com.hp.hpl.jena.util.FileManager - Add location: LocatorURL
301 [main] DEBUG com.hp.hpl.jena.util.FileManager - Add location: ClassLoaderLocator
301 [main] DEBUG com.hp.hpl.jena.util.FileManager - Found: file:ont-policy.rdf (ClassLoaderLocator)
1002 [main] DEBUG com.hp.hpl.jena.util.FileManager - readModel(model,http://www.semanticweb.org/myOnt)
1002 [main] DEBUG com.hp.hpl.jena.util.FileManager - readModel(model,http://www.semanticweb.org/myOnt, null)
1002 [main] DEBUG com.hp.hpl.jena.util.FileManager - Not mapped: http://www.semanticweb.org/myOnt
2065 [main] WARN com.hp.hpl.jena.ontology.OntDocumentManager - An error occurred while attempting to read from http://www.semanticweb.org/myOnt. Msg was 'http://www.semanticweb.org/myOnt'.
This exception is also thrown
com.hp.hpl.jena.shared.DoesNotExistException
I understand that it is unable to find the imported ontology, and that one solution might be to create separate models for both ontologies, but there's an objective property in parent ontology which relates one of its class to the classes of imported ontology.
What can I do?
I am using Neo4j 2.3.0-M03 community version. I have created a database using neo4j import tool. Now when I am going to start the neo4j server, its failing. Any advice? Thanks in advance!
Starting Neo4j Server...WARNING: not changing user
process [21597]... waiting for server to be ready......... Failed to start within 120 seconds.
Neo4j Server may have failed to start, please check the logs.
The log is as follows:
2015-10-14 14:55:35.438-0400 INFO No SSL certificate found, generating a self-signed certificate..
14:55:35.936 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
14:55:36.105 [main] DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
14:55:36.106 [main] DEBUG i.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
14:55:36.107 [main] DEBUG i.n.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
14:55:36.107 [main] DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
14:55:36.108 [main] DEBUG i.n.util.internal.PlatformDependent - Java version: 7
14:55:36.108 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noUnsafe: false
14:55:36.109 [main] DEBUG i.n.util.internal.PlatformDependent - sun.misc.Unsafe: available
14:55:36.109 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noJavassist: false
14:55:36.110 [main] DEBUG i.n.util.internal.PlatformDependent - Javassist: unavailable
14:55:36.110 [main] DEBUG i.n.util.internal.PlatformDependent - You don't have Javassist in your class path or you don't have enough permission to load dynamically generated classes. Please check the configuration for better performance.
14:55:36.110 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.tmpdir: /tmp (java.io.tmpdir)
14:55:36.110 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
14:55:36.110 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
14:55:36.119 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetectionLevel: simple
14:55:36.135 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: unpooled
14:55:36.135 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 65536
2015-10-14 14:55:41.341-0400 INFO Successfully started database
2015-10-14 14:55:41.405-0400 INFO Starting HTTP on port 7474 (32 threads available)
2015-10-14 14:55:41.659-0400 INFO Successfully shutdown Neo4j Server
2015-10-14 14:55:42.224-0400 INFO Successfully stopped database
2015-10-14 14:55:42.227-0400 ERROR Failed to start Neo4j: Starting Neo4j failed: tried to access field org.neo4j.server.rest.repr.RepresentationFormat.mediaType from class org.neo4j.server.rest.repr.RepresentationFormatRepository Starting Neo4j failed: tried to access field org.neo4j.server.rest.repr.RepresentationFormat.mediaType from class org.neo4j.server.rest.repr.RepresentationFormatRepository
org.neo4j.server.ServerStartupException: Starting Neo4j failed: tried to access field org.neo4j.server.rest.repr.RepresentationFormat.mediaType from class org.neo4j.server.rest.repr.RepresentationFormatRepository
at org.neo4j.server.exception.ServerStartupErrors.translateToServerStartupError(ServerStartupErrors.java:67)
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:234)
at org.neo4j.server.Bootstrapper.start(Bootstrapper.java:96)
at org.neo4j.server.CommunityBootstrapper.start(CommunityBootstrapper.java:48)
at org.neo4j.server.CommunityBootstrapper.main(CommunityBootstrapper.java:35)
Caused by: java.lang.IllegalAccessError: tried to access field org.neo4j.server.rest.repr.RepresentationFormat.mediaType from class org.neo4j.server.rest.repr.RepresentationFormatRepository
at org.neo4j.server.rest.repr.RepresentationFormatRepository.<init>(RepresentationFormatRepository.java:46)
at org.neo4j.server.AbstractNeoServer.createDefaultInjectables(AbstractNeoServer.java:641)
at org.neo4j.server.AbstractNeoServer.configureWebServer(AbstractNeoServer.java:360)
at org.neo4j.server.AbstractNeoServer.start(AbstractNeoServer.java:216)
... 3 more
Seems like some permission issue on the lib folder of the Neo4j installation directory.
Try to give full permission to the neo4j installation folder.
Would also suggest to use stable version and not the milestone version.
I could fix it. There was some problem with my embedded database. I tried to run the server with its default graph.db and it run successfully. Now I have to identify what's wrong with the embedded database with I created using import tool.
I've been using the Enyim Memcached Client for .Net, trying to connect to a server running on AppHarbor. The relevant parts of my configuration file look like this:
<enyim.com>
<log factory="Enyim.Caching.DiagnosticsLogFactory, Enyim.Caching" />
<memcached protocol="Binary">
<servers>
<add address="8d593f28-37d7-4c4f-a702-aa7687a85ea1.memcacher.com" port="11211" />
</servers>
<authentication
type="Enyim.Caching.Memcached.PlainTextAuthenticator, Enyim.Caching"
userName="changed to post on stack overflow"
password="changed to post on stack overflow"
zone="AUTHZ"
/>
</memcached>
</enyim.com>
My connection keeps timing out. Any ideas whats going on here? Here are the logs from Enyim client:
2012-01-21 18:56:08 [ERROR] 7 Enyim.Caching.Memcached.MemcachedNode.InternalPoolImpl - Could not init pool. - System.TimeoutException: Could not connect to 50.19.210.46:11211
at Enyim.Caching.Memcached.PooledSocket.ConnectWithTimeout(Socket socket, IPEndPoint endpoint, Int32 timeout)
at Enyim.Caching.Memcached.PooledSocket..ctor(IPEndPoint endpoint, TimeSpan connectionTimeout, TimeSpan receiveTimeout)
at Enyim.Caching.Memcached.MemcachedNode.CreateSocket()
at Enyim.Caching.Memcached.Protocol.Binary.BinaryNode.CreateSocket()
at Enyim.Caching.Memcached.MemcachedNode.InternalPoolImpl.CreateSocket()
at Enyim.Caching.Memcached.MemcachedNode.InternalPoolImpl.InitPool()
2012-01-21 18:56:08 [DEBUG] 7 Enyim.Caching.Memcached.MemcachedNode.InternalPoolImpl - Mark as dead was requested for 50.19.210.46:11211
2012-01-21 18:56:08 [DEBUG] 7 Enyim.Caching.Memcached.MemcachedNode.InternalPoolImpl - FailurePolicy.ShouldFail(): True
2012-01-21 18:56:08 [WARN] 7 Enyim.Caching.Memcached.MemcachedNode.InternalPoolImpl - Marking node 50.19.210.46:11211 as dead
2012-01-21 18:56:08 [DEBUG] 7 Enyim.Caching.Memcached.DefaultServerPool - Node 50.19.210.46:11211 is dead.
2012-01-21 18:56:08 [DEBUG] 7 Enyim.Caching.Memcached.DefaultServerPool - Starting the recovery timer.
2012-01-21 18:56:08 [DEBUG] 7 Enyim.Caching.Memcached.DefaultServerPool - Timer started.
2012-01-21 18:56:08 [DEBUG] 7 Enyim.Caching.Memcached.MemcachedNode.InternalPoolImpl - Acquiring stream from pool. 50.19.210.46:11211
2012-01-21 18:56:08 [DEBUG] 7 Enyim.Caching.Memcached.MemcachedNode.InternalPoolImpl - Pool is dead or disposed, returning null. 50.19.210.46:11211
UPDATE:
Turns out the reason I can't connect to the memcached server is because it's only accessible from appharbor's environment. So for anyone else that runs across this, you need to use a local memcached service when developing locally, then simply change the credentials when deploying (which apphaorbor actually does automatically for you). Problem resolved.
AppHarbor Memcacher buckets are only accessible from AppHarbor application servers. The documentation has been amended to clearly reflect this.
You should use a locally installed memcached server for testing.