This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean tryAcquire(int timeout) { | |
SemaphorePermit permit = new SemaphorePermit(semaphoreName, groupName, | |
acquirerName, null); | |
// Delegate to the gatekeeper which enforces the permit rules based | |
// on the semaphore definition. The gatekeeper might be a local library | |
// or a call to a remote service. | |
permit = gatekeeperGateway.tryAcquire(permit); | |
Date expirationDate = permit.getExpirationDate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final static String KEY_PREFIX = "gatekeeper"; | |
ConcurrentMap definitionMap = hazelcast.getMap(KEY_PREFIX + ".semaphoreDefinitions"); | |
ConcurrentMap permitMap = hazelcast.getMap(KEY_PREFIX + ".semaphorePermits"); | |
// Logic: | |
// - Lookup the definition | |
// - Check the group and acquirer pattern | |
// - Check for an available permit | |
// - Issue the permit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final static String KEY_PREFIX = "gatekeeper"; | |
ConcurrentMap definitionMap = hazelcast.getMap(KEY_PREFIX + ".semaphoreDefinitions"); | |
ConcurrentMap permitMap = hazelcast.getMap(KEY_PREFIX + ".semaphorePermits"); | |
Lock gatekeeperLock = hazelcast.getLock(KEY_PREFIX + ".lock"); | |
if (gatekeeperLock.tryLock(LOCK_WAIT_PERIOD, TimeUnit.SECONDS)) { | |
try { | |
// Logic: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HazelcastInstance hazelcast = Hazelcast.newHazelcastInstance(); | |
HazelcastMQConfig mqConfig = new HazelcastMQConfig(); | |
mqConfig.setHazelcastInstance(hazelcast); | |
HazelcastMQInstance mqInstance = HazelcastMQ.newHazelcastMQInstance(mqConfig); | |
// Create the server. | |
HazelcastMQStompConfig stompConfig = new HazelcastMQStompConfig(mqInstance); | |
HazelcastMQStompInstance stompServer = HazelcastMQStomp.newHazelcastMQStompInstance(stompConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "logstash/filters/base" | |
require "logstash/namespace" | |
# The throttle filter is for throttling the number of events received. The filter | |
# is configured with a lower bound, the before_count, and upper bound, the after_count, | |
# and a period of time. All events passing through the filter will be counted based on | |
# a key_field. As long as the count is less than the before_count or greater than the | |
# after_count, the event will be "throttled" which means the filter will be considered | |
# successful and any tags or fields will be added. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setup the LDAP client (normally done via Spring context file). | |
LdapContextSource contextSource = new LdapContextSource(); | |
contextSource.setUrl("ldap://adserver.mycompany.com:3268"); | |
contextSource.setBase("DC=AD,DC=MYCOMPANY,DC=COM"); | |
contextSource.setUserDn("[email protected]"); | |
contextSource.setPassword("password1"); | |
contextSource.afterPropertiesSet(); | |
LdapTemplate ldapTemplate = new LdapTemplate(contextSource); | |
ldapTemplate.afterPropertiesSet(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.mpilone.vaadin; | |
import java.util.concurrent.*; | |
import java.util.concurrent.locks.Lock; | |
import com.vaadin.server.VaadinSession; | |
import com.vaadin.ui.UI; | |
import com.vaadin.ui.UIDetachedException; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="sessionManager" | |
class="org.mpilone.util.shiro.VaadinSessionManager" /> | |
<bean id="securityManager" class="org.apache.shiro.mgt.DefaultSecurityManager" | |
p:realm-ref="mpiloneRealm" | |
p:sessionManager-ref="sessionManager" /> | |
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/> | |
<bean id="mpiloneRealm" class="org.mpilone.util.shiro.MyCustomRealm" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.prss.mpilone.util.shiro; | |
import java.util.UUID; | |
import org.apache.shiro.session.Session; | |
import org.apache.shiro.session.SessionException; | |
import org.apache.shiro.session.mgt.*; | |
import com.vaadin.server.VaadinSession; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.mpilone.util.shiro; | |
import org.apache.shiro.SecurityUtils; | |
import org.apache.shiro.mgt.DefaultSecurityManager; | |
import org.apache.shiro.mgt.SecurityManager; | |
import org.apache.shiro.subject.PrincipalCollection; | |
import org.apache.shiro.subject.Subject; | |
import org.mpilone.util.shiro.SecurityContext; | |
import com.vaadin.server.VaadinSession; |