Java Code Examples for java.util.concurrent.ConcurrentHashMap

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project fastjson, under directory /src/test/java/com/alibaba/json/bvt/parser/deser/.

Source file: FieldDeserializerTest3.java

  20 
vote

public void test_concurrentMap() throws Exception {
  int featureValues=0;
  DefaultExtJSONParser parser=new DefaultExtJSONParser("{}",ParserConfig.getGlobalInstance(),featureValues);
  DefaultObjectDeserializer objectDeser=new DefaultObjectDeserializer();
  ConcurrentHashMap value=objectDeser.deserialze(parser,ConcurrentHashMap.class);
  Assert.assertEquals(0,value.size());
}
 

Example 2

From project CIShell, under directory /testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/converter/graph/.

Source file: ConverterGraph.java

  18 
vote

public ConverterGraph(ServiceReference[] converterRefs,BundleContext bContext,LogService log){
  this.bContext=bContext;
  this.log=log;
  this.converters=createConverters(converterRefs);
  inDataToConverters=new HashMap();
  outDataToConverters=new HashMap();
  dataFormats=new HashSet();
  fileExtensionTestConverters=new ConcurrentHashMap();
  fileExtensionCompareConverters=new ConcurrentHashMap();
  deriveDataFormats(this.converters,this.dataFormats);
  associateConverters(this.converters,this.inDataToConverters,this.outDataToConverters);
  createConverterPaths(this.inDataToConverters,this.fileExtensionTestConverters,this.fileExtensionCompareConverters);
}
 

Example 3

From project incubator-deltaspike, under directory /deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/provider/.

Source file: BeanProviderTest.java

  17 
vote

/** 
 * lookup by name without type
 */
@Test public void simpleBeanLookupByNameWithoutType(){
{
    Object testBean=BeanProvider.getContextualReference("extraNameBean");
    Assert.assertNotNull(testBean);
    Assert.assertTrue(testBean instanceof TestBean);
    TestBean tb=(TestBean)testBean;
    Assert.assertEquals(4711,tb.getI());
  }
{
    Object testBean=BeanProvider.getContextualReference("extraNameBean",false);
    Assert.assertNotNull(testBean);
    Assert.assertTrue(testBean instanceof TestBean);
    TestBean tb=(TestBean)testBean;
    Assert.assertEquals(4711,tb.getI());
  }
{
    try {
      Object testBean=BeanProvider.getContextualReference("thisBeanDoesNotExist");
      Assert.fail("BeanProvider#getContextualReference should have blown up with a non-existing bean!");
    }
 catch (    IllegalStateException ise) {
    }
  }
{
    try {
      ConcurrentHashMap chm=BeanProvider.getContextualReference(ConcurrentHashMap.class);
      Assert.fail("BeanProvider#getContextualReference should have blown up with a non-existing bean!");
    }
 catch (    IllegalStateException ise) {
    }
  }
}
 

Example 4

From project caseconductor-platform, under directory /utest-domain-services/src/main/java/com/utest/domain/service/impl/.

Source file: StaticDataServiceImpl.java

  16 
vote

@SuppressWarnings("unchecked") private <T>void loadNonTranslatableData(final List<Class> clazzes_){
  if (_codeMap == null) {
    _codeMap=new ConcurrentHashMap();
  }
  if (_parentDependable == null) {
    _parentDependable=new ConcurrentHashMap();
  }
  for (  final Class clazz : clazzes_) {
    final Vector<T> list=new Vector<T>();
    list.addAll(dao.getAll(clazz));
    if (!list.isEmpty()) {
      final Object entity=list.get(0);
      if (entity instanceof ParentDependable) {
        final List converted=list;
        final ConcurrentMap<String,Vector<CodeValueEntity>> filtered=DomainUtil.filterDataByParent(converted);
        for (        Vector<CodeValueEntity> filteredValues : filtered.values()) {
          filteredValues=sortLoadedData(filteredValues);
        }
        _parentDependable.put(clazz.getSimpleName().toUpperCase(),filtered);
      }
      _codeMap.put(clazz.getSimpleName().toUpperCase(),sortLoadedData(DomainUtil.convertToCodeValues(list)));
    }
    _nativeObjects.put(clazz.getSimpleName().toUpperCase(),list);
  }
}
 

Example 5

From project erjang, under directory /src/main/java/erjang/.

Source file: EAbstractNode.java

  16 
vote

public static boolean monitor_nodes(EHandle caller,boolean on,int opts){
  if (on)   nodes_monitors.putIfAbsent(caller,new ConcurrentHashMap());
  ConcurrentHashMap<Integer,AtomicInteger> forHandle=nodes_monitors.get(caller);
  if (forHandle == null)   return false;
  if (on) {
    forHandle.putIfAbsent(opts,new AtomicInteger(0));
    AtomicInteger ami=forHandle.get(opts);
    if (ami == null)     return false;
    int old=ami.getAndIncrement();
    return old > 0;
  }
 else {
    AtomicInteger old=forHandle.remove(opts);
    return old != null && old.get() > 0;
  }
}
 

Example 6

From project aether-core, under directory /aether-connector-asynchttpclient/src/test/java/org/eclipse/aether/connector/async/.

Source file: ResumeGetTest.java

  15 
vote

public FlakyHandler(int requiredRequests){
  this.requiredRequests=requiredRequests;
  madeRequests=new ConcurrentHashMap<String,Integer>();
  totalSize=1024 * 128;
  chunkSize=(requiredRequests > 1) ? totalSize / (requiredRequests - 1) - 1 : totalSize;
}
 

Example 7

From project amplafi-sworddance, under directory /src/main/java/com/sworddance/beans/.

Source file: BeanWorker.java

  15 
vote

/** 
 * Each class has its own version of the PropertyMethodChain map.
 * @param clazz
 * @return PropertyMethodChain map for the passed class.
 */
protected ConcurrentMap<String,PropertyMethodChain> getMethodMap(Class<?> clazz){
  ConcurrentMap<String,PropertyMethodChain> propMap;
  if (!methodsMap.containsKey(clazz)) {
    propMap=new ConcurrentHashMap<String,PropertyMethodChain>();
    for (    String property : NotNullIterator.<String>newNotNullIterator(getPropertyNames())) {
      addPropertyMethodChainIfAbsent(clazz,propMap,property,false);
    }
    methodsMap.putIfAbsent(clazz,propMap);
  }
  propMap=methodsMap.get(clazz);
  return propMap;
}
 

Example 8

From project anadix, under directory /integration/anadix-selenium/src/main/java/org/anadix/utils/.

Source file: MultithreadedAnalyzer.java

  15 
vote

public MultithreadedAnalyzer(Analyzer analyzer,int threads){
  if (analyzer == null) {
    throw new NullPointerException("analyzer can't be null");
  }
  if (threads < 1) {
    throw new IllegalArgumentException("thread count must be greater than or equal to 1");
  }
  this.analyzer=analyzer;
  exec=Executors.newFixedThreadPool(threads);
  results=new ConcurrentHashMap<Integer,Future<Report>>();
}
 

Example 9

From project Android, under directory /app/src/main/java/com/github/mobile/accounts/.

Source file: AccountScope.java

  15 
vote

@Override protected <T>Map<Key<?>,Object> getScopedObjectMap(final Key<T> key){
  GitHubAccount account=currentAccount.get();
  if (account == null)   throw new OutOfScopeException("Cannot access " + key + " outside of a scoping block");
  Map<Key<?>,Object> scopeMap=repoScopeMaps.get(account);
  if (scopeMap == null) {
    scopeMap=new ConcurrentHashMap<Key<?>,Object>();
    scopeMap.put(GITHUB_ACCOUNT_KEY,account);
    repoScopeMaps.put(account,scopeMap);
  }
  return scopeMap;
}
 

Example 10

From project android-async-http, under directory /src/com/loopj/android/http/.

Source file: PersistentCookieStore.java

  15 
vote

/** 
 * Construct a persistent cookie store.
 */
public PersistentCookieStore(Context context){
  cookiePrefs=context.getSharedPreferences(COOKIE_PREFS,0);
  cookies=new ConcurrentHashMap<String,Cookie>();
  String storedCookieNames=cookiePrefs.getString(COOKIE_NAME_STORE,null);
  if (storedCookieNames != null) {
    String[] cookieNames=TextUtils.split(storedCookieNames,",");
    for (    String name : cookieNames) {
      String encodedCookie=cookiePrefs.getString(COOKIE_NAME_PREFIX + name,null);
      if (encodedCookie != null) {
        Cookie decodedCookie=decodeCookie(encodedCookie);
        if (decodedCookie != null) {
          cookies.put(name,decodedCookie);
        }
      }
    }
    clearExpired(new Date());
  }
}
 

Example 11

From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharing/src/com/nostra13/socialsharing/twitter/extpack/winterwell/jtwitter/.

Source file: InternalUtils.java

  15 
vote

/** 
 * @param on true to activate  {@link #getAPIUsageStats()}. false to switch stats off. false by default
 */
static public void setTrackAPIUsage(boolean on){
  if (!on) {
    usage=null;
    return;
  }
  if (usage != null)   return;
  usage=new ConcurrentHashMap<String,Long>();
}
 

Example 12

From project android_packages_apps_Exchange, under directory /src/com/android/exchange/.

Source file: ExchangeService.java

  15 
vote

public void hostChanged(long accountId) throws RemoteException {
  ExchangeService exchangeService=INSTANCE;
  if (exchangeService == null)   return;
  ConcurrentHashMap<Long,SyncError> syncErrorMap=exchangeService.mSyncErrorMap;
  for (  long mailboxId : syncErrorMap.keySet()) {
    SyncError error=syncErrorMap.get(mailboxId);
    Mailbox m=Mailbox.restoreMailboxWithId(exchangeService,mailboxId);
    if (m == null) {
      syncErrorMap.remove(mailboxId);
    }
 else     if (error != null && m.mAccountKey == accountId) {
      error.fatal=false;
      error.holdEndTime=0;
    }
  }
  exchangeService.stopAccountSyncs(accountId,true);
  kick("host changed");
}
 

Example 13

From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/.

Source file: ThumbnailLoader.java

  15 
vote

/** 
 * Used for loading and decoding thumbnails from files.
 * @author PhilipHayes
 * @param context Current application context.
 */
public ThumbnailLoader(Context context){
  mContext=context;
  purger=new Runnable(){
    @Override public void run(){
      Log.d(TAG,"Purge Timer hit; Clearing Caches.");
      clearCaches();
    }
  }
;
  purgeHandler=new Handler();
  mExecutor=Executors.newFixedThreadPool(POOL_SIZE);
  mBlacklist=new ArrayList<String>();
  mSoftBitmapCache=new ConcurrentHashMap<String,SoftReference<Bitmap>>(MAX_CACHE_CAPACITY / 2);
  mHardBitmapCache=new LinkedHashMap<String,Bitmap>(MAX_CACHE_CAPACITY / 2,0.75f,true){
    /** 
 */
    private static final long serialVersionUID=1347795807259717646L;
    @Override protected boolean removeEldestEntry(    LinkedHashMap.Entry<String,Bitmap> eldest){
      if (size() > MAX_CACHE_CAPACITY) {
        mSoftBitmapCache.put(eldest.getKey(),new SoftReference<Bitmap>(eldest.getValue()));
        return true;
      }
 else {
        return false;
      }
    }
  }
;
}
 

Example 14

From project apollo, under directory /injector/src/main/java/com/bskyb/cg/environments/hash/.

Source file: PersistentHash.java

  15 
vote

public PersistentHash(String dirname) throws IOException {
  this.dirname=dirname;
  hash=new ConcurrentHashMap<String,Message>();
  File directory=new File(dirname);
  if (directory.isDirectory()) {
    refreshFromStore(this.dirname);
  }
 else {
    createEmptyStore(this.dirname);
  }
}
 

Example 15

From project archaius, under directory /archaius-core/src/main/java/com/netflix/config/.

Source file: ConcurrentMapConfiguration.java

  15 
vote

/** 
 * Create an instance with an empty map.
 */
public ConcurrentMapConfiguration(){
  map=new ConcurrentHashMap<String,Object>();
  for (int i=0; i < NUM_LOCKS; i++) {
    locks[i]=new ReentrantLock();
  }
}
 

Example 16

From project Arecibo, under directory /agent/src/main/java/com/ning/arecibo/agent/.

Source file: AgentDataCollectorManager.java

  15 
vote

@Inject public AgentDataCollectorManager(AgentConfig agentConfig,EventPublisher eventPublisher,ConfigInitializer initializer,DataSourceUtils dataSourceUtils){
  this.agentConfig=agentConfig;
  this.eventPublisher=eventPublisher;
  this.initializer=initializer;
  this.dataSourceUtils=dataSourceUtils;
  this.collectorMap=new ConcurrentHashMap<String,AgentDataCollector>();
  this.configMap=new ConcurrentHashMap<String,Config>();
  this.perHostSemaphoreMap=new ConcurrentHashMap<String,Semaphore>();
}
 

Example 17

From project arquillian-core, under directory /protocols/jmx/src/main/java/org/jboss/arquillian/protocol/jmx/.

Source file: JMXTestRunner.java

  15 
vote

public JMXTestRunner(TestClassLoader classLoader){
  this.testClassLoader=classLoader;
  if (testClassLoader == null) {
    testClassLoader=new TestClassLoader(){
      public Class<?> loadTestClass(      String className) throws ClassNotFoundException {
        ClassLoader classLoader=JMXTestRunner.class.getClassLoader();
        return classLoader.loadClass(className);
      }
    }
;
  }
  events=new ConcurrentHashMap<String,Command<?>>();
  currentCall=new ThreadLocal<String>();
}
 

Example 18

From project asterisk-java, under directory /src/main/java/org/asteriskjava/manager/internal/.

Source file: ManagerReaderImpl.java

  15 
vote

/** 
 * Creates a new ManagerReaderImpl.
 * @param dispatcher the dispatcher to use for dispatching events and responses.
 * @param source     the source to use when creating {@link ManagerEvent}s
 */
public ManagerReaderImpl(final Dispatcher dispatcher,Object source){
  this.dispatcher=dispatcher;
  this.source=source;
  this.eventBuilder=new EventBuilderImpl();
  this.responseBuilder=new ResponseBuilderImpl();
  this.expectedResponseClasses=new ConcurrentHashMap<String,Class<? extends ManagerResponse>>();
}
 

Example 19

From project AudioBox.fm-JavaLib, under directory /audiobox.fm-core/src/main/java/fm/audiobox/core/models/.

Source file: AbstractEntity.java

  15 
vote

public AbstractEntity(IConfiguration config){
  this.configuration=config;
  this.properties=new ConcurrentHashMap<String,Object>();
  if (log.isTraceEnabled()) {
    log.trace("Entity instantiated: " + this.getNamespace());
  }
}
 

Example 20

From project AutobahnAndroid, under directory /Autobahn/src/de/tavendo/autobahn/.

Source file: WampReader.java

  15 
vote

/** 
 * A reader object is created in AutobahnConnection.
 * @param calls         The call map created on master.
 * @param subs          The event subscription map created on master.
 * @param master        Message handler of master (used by us to notify the master).
 * @param socket        The TCP socket.
 * @param options       WebSockets connection options.
 * @param threadName    The thread name we announce.
 */
public WampReader(ConcurrentHashMap<String,CallMeta> calls,ConcurrentHashMap<String,SubMeta> subs,Handler master,SocketChannel socket,WebSocketOptions options,String threadName){
  super(master,socket,options,threadName);
  mCalls=calls;
  mSubs=subs;
  mJsonMapper=new ObjectMapper();
  mJsonMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
  mJsonFactory=mJsonMapper.getJsonFactory();
  if (DEBUG)   Log.d(TAG,"created");
}
 

Example 21

From project avro, under directory /lang/java/avro/src/main/java/org/apache/avro/data/.

Source file: RecordBuilderBase.java

  15 
vote

/** 
 * Gets the default value of the given field, if any.
 * @param field the field whose default value should be retrieved.
 * @return the default value associated with the given field, or null if none is specified in the schema.
 * @throws IOException 
 */
@SuppressWarnings({"rawtypes","unchecked"}) protected Object defaultValue(Field field) throws IOException {
  JsonNode defaultJsonValue=field.defaultValue();
  if (defaultJsonValue == null) {
    throw new AvroRuntimeException("Field " + field + " not set and has no default value");
  }
  if (defaultJsonValue.isNull() && (field.schema().getType() == Type.NULL || (field.schema().getType() == Type.UNION && field.schema().getTypes().get(0).getType() == Type.NULL))) {
    return null;
  }
  Object defaultValue=null;
  ConcurrentMap<Integer,Object> defaultSchemaValues=DEFAULT_VALUE_CACHE.get(schema.getFullName());
  if (defaultSchemaValues == null) {
    DEFAULT_VALUE_CACHE.putIfAbsent(schema.getFullName(),new ConcurrentHashMap<Integer,Object>(fields.length));
    defaultSchemaValues=DEFAULT_VALUE_CACHE.get(schema.getFullName());
  }
  defaultValue=defaultSchemaValues.get(field.pos());
  if (defaultValue == null) {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    encoder=EncoderFactory.get().binaryEncoder(baos,encoder);
    ResolvingGrammarGenerator.encode(encoder,field.schema(),defaultJsonValue);
    encoder.flush();
    decoder=DecoderFactory.get().binaryDecoder(baos.toByteArray(),decoder);
    defaultValue=data.createDatumReader(field.schema()).read(null,decoder);
    defaultSchemaValues.putIfAbsent(field.pos(),defaultValue);
  }
  return data.deepCopy(field.schema(),defaultValue);
}
 

Example 22

From project azkaban, under directory /azkaban/src/java/azkaban/jobs/.

Source file: JobExecutorManager.java

  15 
vote

@SuppressWarnings("unchecked") public JobExecutorManager(FlowManager allKnownFlows,JobManager jobManager,Mailman mailman,String jobSuccessEmail,String jobFailureEmail,int maxThreads){
  this.jobManager=jobManager;
  this.mailman=mailman;
  this.jobSuccessEmail=jobSuccessEmail;
  this.jobFailureEmail=jobFailureEmail;
  this.allKnownFlows=allKnownFlows;
  Multimap<String,JobExecution> typedMultiMap=HashMultimap.create();
  this.completed=Multimaps.synchronizedMultimap(typedMultiMap);
  this.executing=new ConcurrentHashMap<String,ExecutingJobAndInstance>();
  this.executor=new ThreadPoolExecutor(0,maxThreads,10,TimeUnit.SECONDS,new LinkedBlockingQueue(),new ExecutorThreadFactory());
}
 

Example 23

From project bagheera, under directory /src/main/java/com/mozilla/bagheera/metrics/.

Source file: HttpMetric.java

  15 
vote

private void configureMetrics(){
  requests=Metrics.newMeter(new MetricName(DEFAULT_GROUP,DEFAULT_TYPE,this.id + ".requests"),"requests",TimeUnit.SECONDS);
  throughput=Metrics.newMeter(new MetricName(DEFAULT_GROUP,DEFAULT_TYPE,this.id + ".throughput"),"bytes",TimeUnit.SECONDS);
  methods=new ConcurrentHashMap<String,Meter>();
  responseCodeCounts=new ConcurrentHashMap<Integer,Counter>();
}
 

Example 24

From project blueprint-namespaces, under directory /blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/.

Source file: MapRecipe.java

  15 
vote

public static Class getMap(Class type){
  if (ReflectionUtils.hasDefaultConstructor(type)) {
    return type;
  }
 else   if (SortedMap.class.isAssignableFrom(type)) {
    return TreeMap.class;
  }
 else   if (ConcurrentMap.class.isAssignableFrom(type)) {
    return ConcurrentHashMap.class;
  }
 else {
    return LinkedHashMap.class;
  }
}
 

Example 25

From project capedwarf-green, under directory /jpa/src/main/java/org/jboss/capedwarf/jpa/.

Source file: Relationships.java

  15 
vote

private static Object getMTO(Method method,ManyToOne mto,Object entity,EntityManagerProvider provider) throws Throwable {
  Object rel=method.invoke(entity);
  if (rel == null) {
    Class<?> ec=entity.getClass();
    String methodName=method.getName();
    Class<?> entityClass=method.getReturnType();
    Map<Class<?>,Method> map=getIdMapping.get(ec);
    if (map == null) {
      map=new ConcurrentHashMap<Class<?>,Method>();
      getIdMapping.put(ec,map);
    }
    Method idMethod=map.get(entityClass);
    if (idMethod == null) {
      String idName=mto.id();
      if (idName == null || idName.length() == 0) {
        idName=methodName + "Id";
      }
      idMethod=ec.getMethod(idName);
      map.put(entityClass,idMethod);
    }
    Object id=idMethod.invoke(entity);
    if (id == null) {
      return null;
    }
    EntityManager em=provider.getEntityManager();
    try {
      rel=em.find(entityClass,id);
    }
  finally {
      provider.close(em);
    }
    Method setter=ec.getMethod("s" + methodName.substring(1),entityClass);
    setter.invoke(entity,rel);
  }
  return rel;
}
 

Example 26

From project Carolina-Digital-Repository, under directory /metadata/src/main/java/edu/unc/lib/dl/fedora/.

Source file: AccessControlUtils.java

  15 
vote

public void init(){
  LOG.debug("init entry");
  if (initComplete) {
    LOG.debug("init exit; was already initialized");
    return;
  }
  permissionMap=new ConcurrentHashMap<String,Map>();
  ancestorMap=new ConcurrentHashMap<String,List<PID>>();
  if (tripleStoreQueryService == null) {
    LOG.error("tripleStoreQueryService is NULL");
  }
  collectionsPid=tripleStoreQueryService.fetchByRepositoryPath("/Collections");
  initComplete=true;
  LOG.debug("init exit");
}
 

Example 27

From project cas, under directory /cas-server-core/src/main/java/org/jasig/cas/services/.

Source file: DefaultServicesManagerImpl.java

  15 
vote

private void load(){
  final ConcurrentHashMap<Long,RegisteredService> localServices=new ConcurrentHashMap<Long,RegisteredService>();
  for (  final RegisteredService r : this.serviceRegistryDao.load()) {
    log.debug("Adding registered service " + r.getServiceId());
    localServices.put(r.getId(),r);
  }
  this.services=localServices;
  log.info(String.format("Loaded %s services.",this.services.size()));
}
 

Example 28

From project cdi-extension-showcase, under directory /src/main/java/com/acme/jsfcontext/.

Source file: ViewScopedContext.java

  15 
vote

@SuppressWarnings("unchecked") private Map<Contextual<?>,Object> getComponentInstanceMap(){
  Map<String,Object> viewMap=getViewMap();
  Map<Contextual<?>,Object> map=(ConcurrentHashMap<Contextual<?>,Object>)viewMap.get(COMPONENT_MAP_NAME);
  if (map == null) {
    map=new ConcurrentHashMap<Contextual<?>,Object>();
    viewMap.put(COMPONENT_MAP_NAME,map);
  }
  return map;
}
 

Example 29

From project ceylon-module-resolver, under directory /impl/src/main/java/com/redhat/ceylon/cmr/impl/.

Source file: AbstractOpenNode.java

  15 
vote

@Override public Iterable<? extends Node> getChildren(){
  if (!children.containsKey(NODE_MARKER)) {
    children.put(NODE_MARKER,new MarkerNode());
    ConcurrentMap<String,OpenNode> tmp=new ConcurrentHashMap<String,OpenNode>();
    for (    OpenNode on : findService(StructureBuilder.class).find(this))     put(tmp,on.getLabel(),on);
    children.putAll(tmp);
    return tmp.values();
  }
 else {
    List<Node> nodes=new ArrayList<Node>();
    for (    Node on : children.values()) {
      if (on instanceof MarkerNode == false)       nodes.add(on);
    }
    return nodes;
  }
}
 

Example 30

From project ceylon-runtime, under directory /impl/src/main/java/ceylon/modules/jboss/runtime/.

Source file: Node.java

  15 
vote

Node<T> addChild(String token,T value){
  if (children == null)   children=new ConcurrentHashMap<String,Node<T>>();
  Node<T> child=children.get(token);
  if (child == null) {
    child=new Node<T>(value);
    child.name=token;
    child.parent=this;
    children.put(token,child);
  }
  return child;
}
 

Example 31

From project Citizens, under directory /src/trader/net/citizensnpcs/traders/.

Source file: TraderProperties.java

  15 
vote

private Map<Check,Stockable> getStockables(int UID){
  Map<Check,Stockable> stockables=new ConcurrentHashMap<Check,Stockable>();
  int i=0;
  label:   for (  String s : profiles.getString(UID + stock).split(";")) {
    if (s.isEmpty()) {
      continue;
    }
    i=0;
    ItemStack stack=new ItemStack(37);
    ItemPrice price=new ItemPrice(0);
    boolean selling=false;
    for (    String main : s.split(",")) {
switch (i) {
case 0:
        String[] split=main.split("/");
      stack=new ItemStack(Integer.parseInt(split[0]),Integer.parseInt(split[1]),Short.parseShort(split[2]));
    break;
case 1:
  String[] parts=main.split("/");
if (parts.length == 1 || parts.length == 2) {
  price=new ItemPrice(Double.parseDouble(parts[0]));
}
 else {
  continue label;
}
break;
case 2:
selling=Boolean.parseBoolean(main);
break;
}
i+=1;
}
Stockable stock=new Stockable(stack,price,selling);
stockables.put(stock.createCheck(),stock);
}
return stockables;
}
 

Example 32

From project clojure, under directory /src/jvm/clojure/lang/.

Source file: Util.java

  15 
vote

static public <K,V>void clearCache(ReferenceQueue rq,ConcurrentHashMap<K,Reference<V>> cache){
  if (rq.poll() != null) {
    while (rq.poll() != null)     ;
    for (    Map.Entry<K,Reference<V>> e : cache.entrySet()) {
      Reference<V> val=e.getValue();
      if (val != null && val.get() == null)       cache.remove(e.getKey(),val);
    }
  }
}
 

Example 33

From project cloudbees-api-client, under directory /cloudbees-api-client/src/main/java/com/cloudbees/upload/.

Source file: ArchiveUtils.java

  15 
vote

public static Map<String,Integer> getDeltas(String archiveFile,Map<String,Long> oldCheckSums) throws IOException {
  Map<String,Integer> deltas=new HashMap<String,Integer>();
  Map<String,Long> newCheckSums=getCheckSums(archiveFile);
  ConcurrentHashMap<String,Long> checkSumsTmp=new ConcurrentHashMap<String,Long>(oldCheckSums);
  for (  Map.Entry<String,Long> entry : newCheckSums.entrySet()) {
    String key=entry.getKey();
    if (checkSumsTmp.get(key) == null) {
      deltas.put(key,ENTRY_ADDED);
    }
 else     if (entry.getValue().longValue() != checkSumsTmp.get(key).longValue()) {
      deltas.put(key,ENTRY_UPDATED);
      checkSumsTmp.remove(key);
    }
 else {
      checkSumsTmp.remove(key);
    }
  }
  for (  String key : checkSumsTmp.keySet()) {
    deltas.put(key,ENTRY_DELETED);
  }
  return deltas;
}
 

Example 34

From project cloudhopper-commons-util, under directory /src/main/java/com/cloudhopper/commons/util/windowing/.

Source file: Window.java

  15 
vote

/** 
 * Creates a new window with the specified max window size.  This constructor enables automatic recurring tasks to be executed (such as expiration of requests).
 * @param size The maximum number of requests permitted tobe outstanding (unacknowledged) at a given time.  Must be > 0.
 * @param executor The scheduled executor service to executerecurring tasks (such as expiration of requests).
 * @param monitorInterval The number of milliseconds between executions ofmonitoring tasks.
 * @param listener A listener to send window events to
 * @param monitorThreadName The thread name we'll change to when a monitorrun is executed.  Null if no name change is required.
 */
public Window(int size,ScheduledExecutorService executor,long monitorInterval,WindowListener<K,R,P> listener,String monitorThreadName){
  if (size <= 0) {
    throw new IllegalArgumentException("size must be > 0");
  }
  this.maxSize=size;
  this.futures=new ConcurrentHashMap<K,DefaultWindowFuture<K,R,P>>(size * 2);
  this.lock=new ReentrantLock();
  this.completedCondition=this.lock.newCondition();
  this.pendingOffers=new AtomicInteger(0);
  this.pendingOffersAborted=new AtomicBoolean(false);
  this.executor=executor;
  this.monitorInterval=monitorInterval;
  this.listeners=new CopyOnWriteArrayList<UnwrappedWeakReference<WindowListener<K,R,P>>>();
  if (listener != null) {
    this.listeners.add(new UnwrappedWeakReference<WindowListener<K,R,P>>(listener));
  }
  if (this.executor != null) {
    this.monitor=new WindowMonitor(this,monitorThreadName);
    this.monitorHandle=this.executor.scheduleWithFixedDelay(this.monitor,this.monitorInterval,this.monitorInterval,TimeUnit.MILLISECONDS);
  }
 else {
    this.monitor=null;
    this.monitorHandle=null;
  }
}
 

Example 35

From project CMM-data-grabber, under directory /paul/src/main/java/au/edu/uq/cmm/paul/grabber/.

Source file: WorkEntry.java

  15 
vote

public WorkEntry(Paul services,FileWatcherEvent event,File baseFile){
  this.facility=(Facility)event.getFacility();
  this.timestamp=new Date(event.getTimestamp());
  this.statusManager=services.getFacilityStatusManager();
  this.fileGrabber=statusManager.getStatus(facility).getFileGrabber();
  this.queueManager=services.getQueueManager();
  this.fileManager=queueManager.getFileManager();
  this.baseFile=baseFile;
  this.instrumentBasePath=mapToInstrumentPath(facility,baseFile);
  this.files=new ConcurrentHashMap<File,GrabbedFile>();
  this.holdDatasetsWithNoUser=services.getConfiguration().isHoldDatasetsWithNoUser();
  long timeout=services.getConfiguration().getGrabberTimeout();
  this.grabberTimeout=timeout == 0 ? DEFAULT_GRABBER_TIMEOUT : timeout;
  this.catchup=event.isCatchup();
  settling=facility.getFileSettlingTime();
  if (settling <= 0) {
    settling=FileGrabber.DEFAULT_FILE_SETTLING_TIME;
  }
  addEvent(event);
}
 

Example 36

From project cmsandroid, under directory /src/com/zia/freshdocs/preference/.

Source file: CMISPreferencesManager.java

  15 
vote

@SuppressWarnings("unchecked") protected Map<String,CMISHost> readPreferences(Context ctx){
  ConcurrentHashMap<String,CMISHost> prefs=new ConcurrentHashMap<String,CMISHost>();
  SharedPreferences sharedPrefs=PreferenceManager.getDefaultSharedPreferences(ctx);
  String encPrefs=null;
  if (sharedPrefs.contains(SERVERS_KEY)) {
    encPrefs=sharedPrefs.getString(SERVERS_KEY,null);
    if (encPrefs != null) {
      byte[] repr=Base64.decodeBase64(encPrefs.getBytes());
      Object obj=SerializationUtils.deserialize(repr);
      if (obj != null) {
        prefs=(ConcurrentHashMap<String,CMISHost>)obj;
      }
    }
  }
  return prefs;
}
 

Example 37

From project cocos2d, under directory /cocos2d-android/src/org/cocos2d/actions/.

Source file: CCScheduler.java

  15 
vote

private CCScheduler(){
  timeScale_=1.0f;
  updateSelector="update";
  updates0=new ArrayList<tListEntry>();
  updatesNeg=new ArrayList<tListEntry>();
  updatesPos=new ArrayList<tListEntry>();
  hashForUpdates=new ConcurrentHashMap<Object,tHashSelectorEntry>();
  hashForSelectors=new ConcurrentArrayHashMap<Object,tHashSelectorEntry>();
  currentTarget=null;
  currentTargetSalvaged=false;
}
 

Example 38

From project Coffee-Framework, under directory /coffeeframework-core/src/main/java/coffee/binding/.

Source file: CoffeeBinder.java

  15 
vote

/** 
 * Retrieves a matcher from the RegExp local cache.
 * @param expression
 * @param string
 * @return
 */
public static Matcher getMatcher(String expression,String string){
  if (patternCache == null)   patternCache=new ConcurrentHashMap<String,Pattern>();
  Pattern pattern=patternCache.get(expression);
  if (pattern == null) {
    pattern=Pattern.compile(expression);
    patternCache.put(expression,pattern);
  }
  return pattern.matcher(string);
}
 

Example 39

From project cometd, under directory /cometd-java/cometd-java-examples/src/main/java/org/cometd/examples/.

Source file: ChatService.java

  15 
vote

@Listener("/service/members") public void handleMembership(ServerSession client,ServerMessage message){
  Map<String,Object> data=message.getDataAsMap();
  final String room=((String)data.get("room")).substring("/chat/".length());
  Map<String,String> roomMembers=_members.get(room);
  if (roomMembers == null) {
    Map<String,String> new_room=new ConcurrentHashMap<String,String>();
    roomMembers=_members.putIfAbsent(room,new_room);
    if (roomMembers == null)     roomMembers=new_room;
  }
  final Map<String,String> members=roomMembers;
  String userName=(String)data.get("user");
  members.put(userName,client.getId());
  client.addListener(new ServerSession.RemoveListener(){
    public void removed(    ServerSession session,    boolean timeout){
      members.values().remove(session.getId());
      broadcastMembers(room,members.keySet());
    }
  }
);
  broadcastMembers(room,members.keySet());
}
 

Example 40

From project community-plugins, under directory /deployit-cli-plugins/dar-manifest-exporter/src/main/java/ext/deployit/community/cli/manifestexport/dar/.

Source file: ManifestBuilder.java

  15 
vote

public ManifestBuilder addEntryAttributes(@Nonnull String entryName,@Nonnull Map<String,String> attributes){
  Collection<String> attributeErrors=getAttributeErrors(attributes);
  if (!attributeErrors.isEmpty()) {
    throw new IllegalArgumentException(attributeErrors.toString());
  }
  entryAttributes.putIfAbsent(entryName,new ConcurrentHashMap<String,String>(checkNotNull(attributes).size()));
  entryAttributes.get(entryName).putAll(attributes);
  return this;
}
 

Example 41

From project Core_2, under directory /shell/src/main/java/org/jboss/forge/shell/project/.

Source file: ProjectScopedContext.java

  15 
vote

@SuppressWarnings("unchecked") private Map<Contextual<?>,Object> getComponentInstanceMap(){
  ConcurrentHashMap<Contextual<?>,Object> map=(ConcurrentHashMap<Contextual<?>,Object>)getCurrentProject().getAttribute(COMPONENT_MAP_NAME);
  if (map == null) {
    map=new ConcurrentHashMap<Contextual<?>,Object>();
    getCurrentProject().setAttribute(COMPONENT_MAP_NAME,map);
  }
  return map;
}
 

Example 42

From project core_3, under directory /src/main/java/org/animotron/graph/.

Source file: AnimoGraph.java

  15 
vote

public static boolean startDB(String folder,Map<String,String> config){
  if (graphDb != null) {
    return false;
  }
  System.gc();
  activeTx=Collections.synchronizedList(new LinkedList<Transaction>());
  debugActiveTx=new ConcurrentHashMap<Transaction,Throwable>();
  STORAGE=folder;
  Executor.init();
  graphDb=new EmbeddedGraphDatabase(STORAGE,config);
  BIN=new File(STORAGE,BIN_STORAGE);
  BIN.mkdir();
  TMP=new File(STORAGE,TMP_STORAGE);
  TMP.mkdir();
  initDB();
  Runtime.getRuntime().addShutdownHook(new Thread(){
    public void run(){
      shutdownDB();
    }
  }
);
  return true;
}
 

Example 43

From project core_7, under directory /src/main/java/io/s4/persist/.

Source file: ConMapPersister.java

  15 
vote

public void init(){
  cache=new ConcurrentHashMap<String,CacheEntry>(this.getStartCapacity());
  if (selfClean) {
    Runnable r=new Runnable(){
      public void run(){
        while (!Thread.interrupted()) {
          int cleanCount=ConMapPersister.this.cleanOutGarbage();
          Logger.getLogger(loggerName).info("Cleaned out " + cleanCount + " entries; Persister has "+ cache.size()+ " entries");
          try {
            Thread.sleep(cleanWaitTime * 1000);
          }
 catch (          InterruptedException ie) {
            Thread.currentThread().interrupt();
          }
        }
      }
    }
;
    Thread t=new Thread(r);
    t.start();
    t.setPriority(Thread.MIN_PRIORITY);
  }
}
 

Example 44

From project coverity-plugin, under directory /src/main/java/jenkins/plugins/coverity/.

Source file: CIMInstance.java

  15 
vote

public Long getProjectKey(String projectId) throws IOException, CovRemoteServiceException_Exception {
  if (projectKeys == null) {
    projectKeys=new ConcurrentHashMap<String,Long>();
  }
  Long result=projectKeys.get(projectId);
  if (result == null) {
    result=getProject(projectId).getProjectKey();
    projectKeys.put(projectId,result);
  }
  return result;
}
 

Example 45

From project crunch, under directory /scrunch/src/main/java/org/apache/scrunch/.

Source file: ScalaSafeReflectData.java

  15 
vote

private static Field getField(Class c,String name){
  Map<String,Field> fields=FIELD_CACHE.get(c);
  if (fields == null) {
    fields=new ConcurrentHashMap<String,Field>();
    FIELD_CACHE.put(c,fields);
  }
  Field f=fields.get(name);
  if (f == null) {
    f=findField(c,name);
    fields.put(name,f);
  }
  return f;
}
 

Example 46

From project dawn-tango, under directory /org.dawb.tango.extensions/src/org/dawb/tango/extensions/factory/.

Source file: MockTangoConnection.java

  15 
vote

public MockTangoConnection(String hardwareURI,String attributeName){
  super(hardwareURI,attributeName);
  if (commandMap == null)   createCommandMap();
  this.hardwareName=hardwareURI.substring(hardwareURI.lastIndexOf("/") + 1);
  if (attributeName != null) {
    if (mockListeners == null)     mockListeners=new ConcurrentHashMap<String,AbstractTangoConnection>();
    mockListeners.put(getHardwareName(),this);
    if (mockValues.get(getHardwareName()) == null) {
      mockValues.put(getHardwareName(),0d);
    }
  }
}
 

Example 47

From project dawn-workflow, under directory /org.dawb.passerelle.common/src/org/dawb/passerelle/common/actors/.

Source file: RecordingPortHandler.java

  15 
vote

public void setRecordPorts(boolean recordPorts){
  this.recordPorts=recordPorts;
  if (recordPorts) {
    portRecord=new ConcurrentHashMap<Integer,Object>(7);
  }
 else {
    portRecord=null;
  }
}
 

Example 48

From project Dempsy, under directory /lib-dempsyimpl/src/main/java/com/nokia/dempsy/router/.

Source file: Router.java

  15 
vote

public void stop(){
  try {
    if (mpClusterSession != null)     mpClusterSession.stop();
  }
 catch (  Throwable th) {
    logger.error("Stopping the cluster session " + SafeString.objectDescription(mpClusterSession) + " caused an exception:",th);
  }
  ConcurrentHashMap<Class<?>,Set<ClusterRouter>> map=routerMap;
  routerMap=null;
  Set<ClusterRouter> routers=new HashSet<ClusterRouter>();
  for (  Collection<ClusterRouter> curRouters : map.values())   routers.addAll(curRouters);
  for (  ClusterRouter router : routers)   router.stop();
  for (  RoutingStrategy.Outbound ob : outbounds)   ob.stop();
}
 

Example 49

From project Dempsy-examples, under directory /example-simplewordcount/src/test/java/com/nokia/dempsy/example/simplewordcount/mp/.

Source file: WordRankMPTest.java

  15 
vote

@Test public void cloneTest() throws CloneNotSupportedException {
  WordRankMP clone=mp.clone();
  Assert.assertNotNull(clone);
  Assert.assertNotSame(mp,clone);
  clone.map=new ConcurrentHashMap<Word,WordCount>();
  Assert.assertNull(mp.map);
  Assert.assertNotNull(clone.map);
}
 

Example 50

From project dmix, under directory /JmDNS/src/javax/jmdns/impl/.

Source file: JmDNSImpl.java

  15 
vote

/** 
 * Create an instance of JmDNS and bind it to a specific network interface given its IP-address.
 * @param address IP address to bind to.
 * @param name name of the newly created JmDNS
 * @exception IOException
 */
public JmDNSImpl(InetAddress address,String name) throws IOException {
  super();
  if (logger.isLoggable(Level.FINER)) {
    logger.finer("JmDNS instance created");
  }
  _cache=new DNSCache(100);
  _listeners=Collections.synchronizedList(new ArrayList<DNSListener>());
  _serviceListeners=new ConcurrentHashMap<String,List<ServiceListenerStatus>>();
  _typeListeners=Collections.synchronizedSet(new HashSet<ServiceTypeListenerStatus>());
  _serviceCollectors=new ConcurrentHashMap<String,ServiceCollector>();
  _services=new ConcurrentHashMap<String,ServiceInfo>(20);
  _serviceTypes=new ConcurrentHashMap<String,ServiceTypeEntry>(20);
  _localHost=HostInfo.newHostInfo(address,this,name);
  _name=(name != null ? name : _localHost.getName());
  this.openMulticastSocket(this.getLocalHost());
  this.start(this.getServices().values());
  this.startReaper();
}
 

Example 51

From project doorkeeper, under directory /core/src/main/java/net/dataforte/doorkeeper/account/provider/ldap/.

Source file: LdapAccountProvider.java

  15 
vote

@PostConstruct public void init(){
  if (url == null) {
    throw new IllegalStateException("Parameter 'url' is required");
  }
  if (searchBase == null) {
    throw new IllegalStateException("Parameter 'searchBase' is required");
  }
  cache=new ConcurrentHashMap<String,Object>();
  attributeMap.put(uidAttribute,null);
  if (memberOfAttribute != null) {
    attributeMap.put(memberOfAttribute,null);
  }
  userReturnedAttributes=attributeMap.keySet().toArray(new String[attributeMap.size()]);
  ouMap=new HashMap<Pattern,String>();
  env=new Hashtable<String,String>();
  env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
  env.put(Context.PROVIDER_URL,url);
  env.put(Context.SECURITY_AUTHENTICATION,"simple");
  if (principal != null) {
    env.put(Context.SECURITY_PRINCIPAL,principal);
    env.put(Context.SECURITY_CREDENTIALS,credentials);
  }
  if (log.isInfoEnabled()) {
    log.info("Initialized");
  }
}
 

Example 52

From project dragon, under directory /hadoop-dragon-core/src/main/java/org/apache/hadoop/realtime/records/impl/pb/.

Source file: CounterGroupPBImpl.java

  15 
vote

private void initCounters(){
  if (this.counters != null) {
    return;
  }
  CounterGroupProtoOrBuilder p=viaProto ? proto : builder;
  List<StringCounterMapProto> list=p.getCountersList();
  this.counters=new ConcurrentHashMap<String,Counter>();
  for (  StringCounterMapProto c : list) {
    this.counters.put(c.getKey(),convertFromProtoFormat(c.getValue()));
  }
}
 

Example 53

From project droolsjbpm-integration, under directory /drools-container/drools-spring/src/main/java/org/drools/grid/impl/.

Source file: GridImpl.java

  15 
vote

public GridImpl(Map<String,Object> services){
  if (services == null) {
    this.services=new ConcurrentHashMap<String,Object>();
  }
 else {
    this.services=services;
  }
  this.id=UUID.randomUUID().toString();
  init();
}
 

Example 54

From project en, under directory /src/l1j/server/server/model/.

Source file: L1World.java

  15 
vote

@SuppressWarnings("unchecked") private L1World(){
  _allPlayers=new ConcurrentHashMap<String,L1PcInstance>();
  _allPets=new ConcurrentHashMap<Integer,L1PetInstance>();
  _allSummons=new ConcurrentHashMap<Integer,L1SummonInstance>();
  _allObjects=new ConcurrentHashMap<Integer,L1Object>();
  _visibleObjects=new ConcurrentHashMap[MAX_MAP_ID + 1];
  _allWars=new CopyOnWriteArrayList<L1War>();
  _allClans=new ConcurrentHashMap<String,L1Clan>();
  for (int i=0; i <= MAX_MAP_ID; i++) {
    _visibleObjects[i]=new ConcurrentHashMap<Integer,L1Object>();
  }
}
 

Example 55

From project enterprise, under directory /consistency-check/src/main/java/org/neo4j/consistency/checking/full/.

Source file: OwnerCheck.java

  15 
vote

private static Map<RecordType,ConcurrentMap<Long,DynamicOwner>> initialize(DynamicStore[] stores){
  EnumMap<RecordType,ConcurrentMap<Long,DynamicOwner>> map=new EnumMap<RecordType,ConcurrentMap<Long,DynamicOwner>>(RecordType.class);
  for (  DynamicStore store : stores) {
    map.put(store.type,new ConcurrentHashMap<Long,DynamicOwner>(16,0.75f,4));
  }
  return unmodifiableMap(map);
}
 

Example 56

From project eucalyptus, under directory /clc/modules/core/src/edu/ucsb/eucalyptus/util/.

Source file: CaseInsensitiveMap.java

  15 
vote

public CaseInsensitiveMap(Map m){
  map=new ConcurrentHashMap<String,String>();
  Iterator iterator=m.keySet().iterator();
  while (iterator.hasNext()) {
    Object key=iterator.next();
    map.put(key.toString().toLowerCase(),(String)m.get(key));
  }
}
 

Example 57

From project ExperienceMod, under directory /ExperienceMod/src/com/comphenix/xp/extra/.

Source file: ServiceProvider.java

  15 
vote

/** 
 * Copy everything from the given provider.
 * @param other - the given provider.
 */
public ServiceProvider(ServiceProvider<TService> other){
  this.defaultName=other.defaultName;
  this.nameLookup=new ConcurrentHashMap<String,TService>(other.nameLookup);
  this.disabledLookup=Sets.newSetFromMap(new ConcurrentHashMap<String,Boolean>());
  for (  String disabled : other.disabledLookup) {
    this.disabledLookup.add(disabled);
  }
}
 

Example 58

From project Extlet6, under directory /liferay-6.0.5-patch/portal-impl/src/com/liferay/portal/service/impl/.

Source file: PortletLocalServiceImpl.java

  15 
vote

private Map<String,Portlet> _getPortletsPool(long companyId) throws SystemException {
  String key=_encodeKey(companyId);
  Map<String,Portlet> portletsPool=(Map<String,Portlet>)_companyPortletsPool.get(key);
  if (portletsPool == null) {
    portletsPool=new ConcurrentHashMap<String,Portlet>();
    Map<String,Portlet> parentPortletsPool=_getPortletsPool();
    if (parentPortletsPool == null) {
      return portletsPool;
    }
    for (    Portlet portlet : parentPortletsPool.values()) {
      portlet=(Portlet)portlet.clone();
      portlet.setCompanyId(companyId);
      portletsPool.put(portlet.getPortletId(),portlet);
    }
    List<Portlet> portlets=portletPersistence.findByCompanyId(companyId);
    for (    Portlet portlet : portlets) {
      Portlet portletModel=portletsPool.get(portlet.getPortletId());
      if (portletModel != null) {
        portletModel.setPluginPackage(portlet.getPluginPackage());
        portletModel.setDefaultPluginSetting(portlet.getDefaultPluginSetting());
        portletModel.setRoles(portlet.getRoles());
        portletModel.setActive(portlet.getActive());
      }
    }
    _companyPortletsPool.put(key,portletsPool);
  }
  return portletsPool;
}
 

Example 59

From project faces_1, under directory /impl/src/main/java/org/jboss/seam/faces/context/.

Source file: RenderScopedContext.java

  15 
vote

@SuppressWarnings("unchecked") private Map<Contextual<?>,Object> getComponentInstanceMap(){
  ConcurrentHashMap<Contextual<?>,Object> map=(ConcurrentHashMap<Contextual<?>,Object>)getCurrentRenderContext().get(COMPONENT_MAP_NAME);
  if (map == null) {
    map=new ConcurrentHashMap<Contextual<?>,Object>();
    getCurrentRenderContext().put(COMPONENT_MAP_NAME,map);
  }
  return map;
}
 

Example 60

From project Faye-Android, under directory /src/com/b3rwynmobile/fayeclient/autobahn/.

Source file: WampReader.java

  15 
vote

/** 
 * A reader object is created in AutobahnConnection.
 * @param calls         The call map created on master.
 * @param subs          The event subscription map created on master.
 * @param master        Message handler of master (used by us to notify the master).
 * @param socket        The TCP socket.
 * @param options       WebSockets connection options.
 * @param threadName    The thread name we announce.
 */
public WampReader(ConcurrentHashMap<String,CallMeta> calls,ConcurrentHashMap<String,SubMeta> subs,Handler master,SocketChannel socket,WebSocketOptions options,String threadName){
  super(master,socket,options,threadName);
  mCalls=calls;
  mSubs=subs;
  mJsonMapper=new ObjectMapper();
  mJsonMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
  mJsonFactory=mJsonMapper.getJsonFactory();
  if (DEBUG)   Log.d(TAG,"created");
}
 

Example 61

From project filemanager, under directory /FileManager/src/org/openintents/filemanager/.

Source file: ThumbnailLoader.java

  15 
vote

/** 
 * Used for loading and decoding thumbnails from files.
 * @author PhilipHayes
 * @param context Current application context.
 */
public ThumbnailLoader(Context context){
  mContext=context;
  purger=new Runnable(){
    @Override public void run(){
      Log.d(TAG,"Purge Timer hit; Clearing Caches.");
      clearCaches();
    }
  }
;
  purgeHandler=new Handler();
  mExecutor=Executors.newFixedThreadPool(POOL_SIZE);
  mBlacklist=new ArrayList<String>();
  mSoftBitmapCache=new ConcurrentHashMap<String,SoftReference<Bitmap>>(MAX_CACHE_CAPACITY / 2);
  mHardBitmapCache=new LinkedHashMap<String,Bitmap>(MAX_CACHE_CAPACITY / 2,0.75f,true){
    /** 
 */
    private static final long serialVersionUID=1347795807259717646L;
    @Override protected boolean removeEldestEntry(    LinkedHashMap.Entry<String,Bitmap> eldest){
      if (size() > MAX_CACHE_CAPACITY) {
        mSoftBitmapCache.put(eldest.getKey(),new SoftReference<Bitmap>(eldest.getValue()));
        return true;
      }
 else {
        return false;
      }
    }
  }
;
}
 

Example 62

From project fitnesse, under directory /src/fit/.

Source file: RowFixture.java

  15 
vote

protected Map<Object,Object> eSort(List<?> list,int col){
  TypeAdapter a=columnBindings[col].adapter;
  Map<Object,Object> result=new ConcurrentHashMap<Object,Object>(list.size());
  for (Iterator<?> i=list.iterator(); i.hasNext(); ) {
    Parse row=(Parse)i.next();
    Parse cell=row.parts.at(col);
    try {
      Object key=a.parse(cell.text());
      bin(result,key,row);
    }
 catch (    Exception e) {
      exception(cell,e);
      for (Parse rest=cell.more; rest != null; rest=rest.more) {
        ignore(rest);
      }
    }
  }
  return result;
}
 

Example 63

From project floodlight, under directory /src/main/java/net/floodlightcontroller/core/internal/.

Source file: Controller.java

  15 
vote

/** 
 * Initialize internal data structures
 */
public void init(Map<String,String> configParams){
  this.messageListeners=new ConcurrentHashMap<OFType,ListenerDispatcher<OFType,IOFMessageListener>>();
  this.switchListeners=new CopyOnWriteArraySet<IOFSwitchListener>();
  this.haListeners=new CopyOnWriteArraySet<IHAListener>();
  this.activeSwitches=new ConcurrentHashMap<Long,IOFSwitch>();
  this.connectedSwitches=new HashSet<OFSwitchImpl>();
  this.controllerNodeIPsCache=new HashMap<String,String>();
  this.updates=new LinkedBlockingQueue<IUpdate>();
  this.factory=new BasicFactory();
  this.providerMap=new HashMap<String,List<IInfoProvider>>();
  setConfigParams(configParams);
  this.role=getInitialRole(configParams);
  this.roleChanger=new RoleChanger();
  initVendorMessages();
  this.systemStartTime=System.currentTimeMillis();
}
 

Example 64

From project flume, under directory /flume-ng-core/src/test/java/org/apache/flume/source/.

Source file: TestMultiportSyslogTCPSource.java

  15 
vote

/** 
 * Test the reassembly of a single line across multiple packets.
 */
@Test public void testFragmented() throws CharacterCodingException {
  final int maxLen=100;
  IoBuffer savedBuf=IoBuffer.allocate(maxLen);
  String origMsg="<1>- - blah blam foo\n";
  IoBuffer buf1=IoBuffer.wrap(origMsg.substring(0,11).getBytes(Charsets.UTF_8));
  IoBuffer buf2=IoBuffer.wrap(origMsg.substring(11,16).getBytes(Charsets.UTF_8));
  IoBuffer buf3=IoBuffer.wrap(origMsg.substring(16,21).getBytes(Charsets.UTF_8));
  LineSplitter lineSplitter=new LineSplitter(maxLen);
  ParsedBuffer parsedLine=new ParsedBuffer();
  Assert.assertFalse("Incomplete line should not be parsed",lineSplitter.parseLine(buf1,savedBuf,parsedLine));
  Assert.assertFalse("Incomplete line should not be parsed",lineSplitter.parseLine(buf2,savedBuf,parsedLine));
  Assert.assertTrue("Completed line should be parsed",lineSplitter.parseLine(buf3,savedBuf,parsedLine));
  Assert.assertEquals(origMsg.trim(),parsedLine.buffer.getString(Charsets.UTF_8.newDecoder()));
  parsedLine.buffer.rewind();
  MultiportSyslogTCPSource.MultiportSyslogHandler handler=new MultiportSyslogTCPSource.MultiportSyslogHandler(maxLen,100,null,null,SyslogSourceConfigurationConstants.DEFAULT_PORT_HEADER,new ThreadSafeDecoder(Charsets.UTF_8),new ConcurrentHashMap<Integer,ThreadSafeDecoder>());
  Event event=handler.parseEvent(parsedLine,Charsets.UTF_8.newDecoder());
  String body=new String(event.getBody(),Charsets.UTF_8);
  Assert.assertEquals("Event body incorrect",origMsg.trim().substring(7),body);
}
 

Example 65

From project flume_1, under directory /flume-core/src/main/java/com/cloudera/flume/handlers/text/.

Source file: TailDirSource.java

  15 
vote

/** 
 * Must be synchronized to isolate watcher
 */
@Override synchronized public void open() throws IOException {
  Preconditions.checkState(watcher == null,"Attempting to open an already open TailDirSource (" + dir + ", \""+ regex+ "\")");
  subdirWatcherMap=new ConcurrentHashMap<String,DirWatcher>();
  watcher=createWatcher(dir,regex,recurseDepth);
  dirChecked=true;
  watcher.start();
  tail.open();
}
 

Example 66

From project gansenbang, under directory /s4/s4-core/src/main/java/io/s4/persist/.

Source file: ConMapPersister.java

  15 
vote

public void init(){
  cache=new ConcurrentHashMap<String,CacheEntry>(this.getStartCapacity());
  if (selfClean) {
    Runnable r=new Runnable(){
      public void run(){
        while (!Thread.interrupted()) {
          int cleanCount=ConMapPersister.this.cleanOutGarbage();
          Logger.getLogger(loggerName).info("Cleaned out " + cleanCount + " entries; Persister has "+ cache.size()+ " entries");
          try {
            Thread.sleep(cleanWaitTime * 1000);
          }
 catch (          InterruptedException ie) {
            Thread.currentThread().interrupt();
          }
        }
      }
    }
;
    Thread t=new Thread(r);
    t.start();
    t.setPriority(Thread.MIN_PRIORITY);
  }
}
 

Example 67

From project gatein-common, under directory /common/src/main/java/org/gatein/common/i18n/.

Source file: CachingLocaleFormat.java

  15 
vote

/** 
 * @param delegate the delegate when the cache value has not been found
 * @throws IllegalArgumentException if the delegate object provided is null
 */
public CachingLocaleFormat(LocaleFormat delegate) throws IllegalArgumentException {
  if (delegate == null) {
    throw new IllegalArgumentException("No null delegate is possible");
  }
  this.delegate=delegate;
  this.localeCache=new ConcurrentHashMap<String,Locale>();
  this.stringCache=new ConcurrentHashMap<Locale,String>();
}
 

Example 68

From project gatein-toolbox, under directory /sqlman/src/main/java/org/sqlman/.

Source file: Configuration.java

  15 
vote

ConcurrentMap<Integer,Statistic> buildMap(){
  ConcurrentMap<Integer,Statistic> map=new ConcurrentHashMap<Integer,Statistic>();
  for (int i=0; i < pkgs.length; i++) {
    map.put(i,new Statistic());
  }
  map.put(-1,new Statistic());
  return map;
}
 

Example 69

From project gda-common-rcp, under directory /uk.ac.gda.common.rcp/src/uk/ac/gda/richbeans/beans/.

Source file: BeanUI.java

  15 
vote

/** 
 * You can add a field associated with a bean (even if it is viewing a property and not actually  editing one). All editing fields are added through reflection with setBeanFields(...) however some are not fields and still can be listened to.
 * @param beanClazz
 * @param fieldName
 * @param box
 */
public static void addBeanField(Class<? extends Object> beanClazz,String fieldName,final IFieldWidget box){
  fieldName=fieldName.substring(0,1).toLowerCase(Locale.US) + fieldName.substring(1);
  if (cachedWidgets == null)   cachedWidgets=new ConcurrentHashMap<String,IFieldWidget>(89);
  final String id=beanClazz.getName() + ":" + fieldName;
  cachedWidgets.put(id,box);
  if (waitingListeners != null) {
    final Collection<ValueListener> listeners=waitingListeners.get(id);
    if (listeners != null) {
      for (      ValueListener valueListener : listeners)       box.addValueListener(valueListener);
      waitingListeners.remove(id);
    }
  }
}
 

Example 70

From project gecko, under directory /src/main/java/com/taobao/gecko/core/util/.

Source file: MyMBeanServer.java

  15 
vote

private String getId(final String name,final String idPrefix){
  ConcurrentHashMap<String,AtomicLong> subMap=this.idMap.get(name);
  if (null == subMap) {
    this.lock.lock();
    try {
      subMap=this.idMap.get(name);
      if (null == subMap) {
        subMap=new ConcurrentHashMap<String,AtomicLong>();
        this.idMap.put(name,subMap);
      }
    }
  finally {
      this.lock.unlock();
    }
  }
  AtomicLong indexValue=subMap.get(idPrefix);
  if (null == indexValue) {
    this.lock.lock();
    try {
      indexValue=subMap.get(idPrefix);
      if (null == indexValue) {
        indexValue=new AtomicLong(0);
        subMap.put(idPrefix,indexValue);
      }
    }
  finally {
      this.lock.unlock();
    }
  }
  final long value=indexValue.incrementAndGet();
  final String result=idPrefix + "-" + value;
  return result;
}
 

Example 71

From project Gemini-Blueprint, under directory /core/src/main/java/org/eclipse/gemini/blueprint/blueprint/container/support/.

Source file: BlueprintEditorRegistrar.java

  15 
vote

public void registerCustomEditors(PropertyEditorRegistry registry){
  registry.registerCustomEditor(Date.class,new DateEditor());
  registry.registerCustomEditor(Stack.class,new BlueprintCustomCollectionEditor(Stack.class));
  registry.registerCustomEditor(Vector.class,new BlueprintCustomCollectionEditor(Vector.class));
  registry.registerCustomEditor(Collection.class,new BlueprintCustomCollectionEditor(Collection.class));
  registry.registerCustomEditor(Set.class,new BlueprintCustomCollectionEditor(Set.class));
  registry.registerCustomEditor(SortedSet.class,new BlueprintCustomCollectionEditor(SortedSet.class));
  registry.registerCustomEditor(List.class,new BlueprintCustomCollectionEditor(List.class));
  registry.registerCustomEditor(SortedMap.class,new CustomMapEditor(SortedMap.class));
  registry.registerCustomEditor(HashSet.class,new BlueprintCustomCollectionEditor(HashSet.class));
  registry.registerCustomEditor(LinkedHashSet.class,new BlueprintCustomCollectionEditor(LinkedHashSet.class));
  registry.registerCustomEditor(TreeSet.class,new BlueprintCustomCollectionEditor(TreeSet.class));
  registry.registerCustomEditor(ArrayList.class,new BlueprintCustomCollectionEditor(ArrayList.class));
  registry.registerCustomEditor(LinkedList.class,new BlueprintCustomCollectionEditor(LinkedList.class));
  registry.registerCustomEditor(HashMap.class,new CustomMapEditor(HashMap.class));
  registry.registerCustomEditor(LinkedHashMap.class,new CustomMapEditor(LinkedHashMap.class));
  registry.registerCustomEditor(Hashtable.class,new CustomMapEditor(Hashtable.class));
  registry.registerCustomEditor(TreeMap.class,new CustomMapEditor(TreeMap.class));
  registry.registerCustomEditor(Properties.class,new PropertiesEditor());
  registry.registerCustomEditor(ConcurrentMap.class,new CustomMapEditor(ConcurrentHashMap.class));
  registry.registerCustomEditor(ConcurrentHashMap.class,new CustomMapEditor(ConcurrentHashMap.class));
  registry.registerCustomEditor(Queue.class,new BlueprintCustomCollectionEditor(LinkedList.class));
  registry.registerCustomEditor(Dictionary.class,new CustomMapEditor(Hashtable.class));
}
 

Example 72

From project geronimo-xbean, under directory /xbean-reflect/src/main/java/org/apache/xbean/recipe/.

Source file: MapRecipe.java

  15 
vote

public MapRecipe(Map<?,?> map){
  if (map == null)   throw new NullPointerException("map is null");
  entries=new ArrayList<Object[]>(map.size());
  if (RecipeHelper.hasDefaultConstructor(map.getClass())) {
    this.typeClass=map.getClass();
  }
 else   if (map instanceof SortedMap) {
    this.typeClass=TreeMap.class;
  }
 else   if (map instanceof ConcurrentMap) {
    this.typeClass=ConcurrentHashMap.class;
  }
 else {
    this.typeClass=LinkedHashMap.class;
  }
  putAll(map);
}
 

Example 73

From project giraph, under directory /src/main/java/org/apache/giraph/comm/requests/.

Source file: SendPartitionMutationsRequest.java

  15 
vote

@Override public void doRequest(ServerData<I,V,E,M> serverData){
  ConcurrentHashMap<I,VertexMutations<I,V,E,M>> vertexMutations=serverData.getVertexMutations();
  for (  Entry<I,VertexMutations<I,V,E,M>> entry : vertexIdMutations.entrySet()) {
    VertexMutations<I,V,E,M> mutations=vertexMutations.get(entry.getKey());
    if (mutations == null) {
      mutations=vertexMutations.putIfAbsent(entry.getKey(),entry.getValue());
      if (mutations == null) {
        continue;
      }
    }
synchronized (mutations) {
      mutations.addVertexMutations(entry.getValue());
    }
  }
}
 

Example 74

From project grails-data-mapping, under directory /grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/core/.

Source file: AbstractAttributeStoringSession.java

  15 
vote

public void setAttribute(Object entity,String attributeName,Object value){
  if (entity == null) {
    return;
  }
  int id=System.identityHashCode(entity);
  Map<String,Object> attrs=attributes.get(id);
  if (attrs == null) {
    attrs=new ConcurrentHashMap<String,Object>();
    attributes.put(id,attrs);
  }
  if (attributeName != null && value != null) {
    attrs.put(attributeName,value);
  }
}
 

Example 75

From project grid-goggles, under directory /Dependent Libraries/controlP5/src/controlP5/.

Source file: ControlBroadcaster.java

  15 
vote

protected ControlBroadcaster(ControlP5 theControlP5){
  cp5=theControlP5;
  _myControlListeners=new ArrayList<ControlListener>();
  _myControllerCallbackListeners=new ConcurrentHashMap<CallbackListener,Controller>();
  _myControlEventPlug=checkObject(cp5.papplet,getEventMethod(),new Class[]{ControlEvent.class});
  _myControllerCallbackEventPlug=checkObject(cp5.papplet,_myControllerCallbackEventMethod,new Class[]{CallbackEvent.class});
  if (_myControlEventPlug != null) {
    _myControlEventType=ControlP5Constants.METHOD;
  }
}
 

Example 76

From project griffon, under directory /subprojects/griffon-shell/src/main/groovy/org/apache/felix/gogo/commands/converter/.

Source file: GriffonDefaultConverter.java

  15 
vote

private static Class getMap(Class type){
  if (hasDefaultConstructor(type)) {
    return type;
  }
 else   if (SortedMap.class.isAssignableFrom(type)) {
    return TreeMap.class;
  }
 else   if (ConcurrentMap.class.isAssignableFrom(type)) {
    return ConcurrentHashMap.class;
  }
 else {
    return LinkedHashMap.class;
  }
}
 

Example 77

From project hawtjournal, under directory /src/main/java/org/fusesource/hawtjournal/api/.

Source file: DataFileAccessor.java

  15 
vote

private RandomAccessFile getOrCreateRaf(Thread thread,Integer file) throws IOException {
  ConcurrentMap<Integer,RandomAccessFile> rafs=perThreadDataFileRafs.get(thread);
  if (rafs == null) {
    rafs=new ConcurrentHashMap<Integer,RandomAccessFile>();
    perThreadDataFileRafs.put(thread,rafs);
  }
  RandomAccessFile raf=rafs.get(file);
  if (raf == null) {
    raf=journal.getDataFiles().get(file).openRandomAccessFile();
    rafs.put(file,raf);
  }
  return raf;
}
 

Example 78

From project hazelcast-cluster-monitor, under directory /src/main/java/com/hazelcast/monitor/server/.

Source file: SessionObject.java

  15 
vote

private static Map<Instance.InstanceType,InstanceType> fillMatchMap(){
  Map<Instance.InstanceType,InstanceType> map=new ConcurrentHashMap<Instance.InstanceType,InstanceType>();
  map.put(Instance.InstanceType.MAP,InstanceType.MAP);
  map.put(Instance.InstanceType.SET,InstanceType.SET);
  map.put(Instance.InstanceType.LIST,InstanceType.LIST);
  map.put(Instance.InstanceType.QUEUE,InstanceType.QUEUE);
  map.put(Instance.InstanceType.MULTIMAP,InstanceType.MULTIMAP);
  map.put(Instance.InstanceType.TOPIC,InstanceType.TOPIC);
  map.put(Instance.InstanceType.LOCK,InstanceType.LOCK);
  map.put(Instance.InstanceType.ID_GENERATOR,InstanceType.ID_GENERATOR);
  return map;
}
 

Example 79

From project heritrix3, under directory /commons/src/main/java/org/archive/spring/.

Source file: PathSharingContext.java

  15 
vote

/** 
 * @return a shared map for arbitrary use during a crawl; for example, couldbe used for state persisting for the duration of the crawl, shared among ScriptedProcessor, scripting console, etc scripts
 */
public ConcurrentHashMap<Object,Object> getData(){
  if (data == null) {
    data=new ConcurrentHashMap<Object,Object>();
  }
  return data;
}
 

Example 80

From project hibernate-dsc, under directory /src/main/java/com/corundumstudio/hibernate/dsc/.

Source file: QueryCacheEntityListener.java

  15 
vote

public <T>void register(Class<T> clazz,String regionName,CacheCallback<T> handler){
  ConcurrentMap<String,QueryListenerEntry> values=map.get(clazz);
  if (values == null) {
    values=new ConcurrentHashMap<String,QueryListenerEntry>();
    ConcurrentMap<String,QueryListenerEntry> oldValues=map.putIfAbsent(clazz,values);
    if (oldValues != null) {
      values=oldValues;
    }
  }
  QueryListenerEntry entry=values.get(regionName);
  if (entry == null) {
    entry=new QueryListenerEntry(regionName,handler);
    values.putIfAbsent(regionName,entry);
  }
}
 

Example 81

From project hibernate-ogm, under directory /hibernate-ogm-infinispan/src/main/java/org/hibernate/ogm/datastore/infinispan/impl/.

Source file: InfinispanDatastoreProvider.java

  15 
vote

/** 
 * Need to make sure all needed caches are started before state transfer happens. This prevents this node to return undefined cache errors during replication when other nodes join this one.
 * @param cacheManager
 */
private void eagerlyInitializeCaches(EmbeddedCacheManager cacheManager){
  caches=new ConcurrentHashMap<String,Cache>(3);
  putInLocalCache(cacheManager,DefaultDatastoreNames.ASSOCIATION_STORE);
  putInLocalCache(cacheManager,DefaultDatastoreNames.ENTITY_STORE);
  putInLocalCache(cacheManager,DefaultDatastoreNames.IDENTIFIER_STORE);
}
 

Example 82

From project hoop, under directory /hoop-server/src/main/java/com/cloudera/lib/service/instrumentation/.

Source file: InstrumentationService.java

  15 
vote

@Override @SuppressWarnings("unchecked") public void init() throws ServiceException {
  timersSize=getServiceConfig().getInt(CONF_TIMERS_SIZE,10);
  counterLock=new ReentrantLock();
  timerLock=new ReentrantLock();
  variableLock=new ReentrantLock();
  samplerLock=new ReentrantLock();
  jvmVariables=new ConcurrentHashMap<String,VariableHolder>();
  counters=new ConcurrentHashMap<String,Map<String,AtomicLong>>();
  timers=new ConcurrentHashMap<String,Map<String,Timer>>();
  variables=new ConcurrentHashMap<String,Map<String,VariableHolder>>();
  samplers=new ConcurrentHashMap<String,Map<String,Sampler>>();
  samplersList=new ArrayList<Sampler>();
  all=new LinkedHashMap<String,Map<String,?>>();
  all.put("os-env",System.getenv());
  all.put("sys-props",(Map<String,?>)(Map)System.getProperties());
  all.put("jvm",jvmVariables);
  all.put("counters",(Map)counters);
  all.put("timers",(Map)timers);
  all.put("variables",(Map)variables);
  all.put("samplers",(Map)samplers);
  jvmVariables.put("free.memory",new VariableHolder<Long>(new Instrumentation.Variable<Long>(){
    public Long getValue(){
      return Runtime.getRuntime().freeMemory();
    }
  }
));
  jvmVariables.put("max.memory",new VariableHolder<Long>(new Instrumentation.Variable<Long>(){
    public Long getValue(){
      return Runtime.getRuntime().maxMemory();
    }
  }
));
  jvmVariables.put("total.memory",new VariableHolder<Long>(new Instrumentation.Variable<Long>(){
    public Long getValue(){
      return Runtime.getRuntime().totalMemory();
    }
  }
));
}
 

Example 83

From project hotpotato, under directory /src/main/java/com/biasedbit/hotpotato/session/.

Source file: DefaultHttpSession.java

  15 
vote

public DefaultHttpSession(HttpClient client,HttpClient httpsClient){
  if (client.isHttps()) {
    throw new IllegalArgumentException("HTTP client must not have SSL (HTTPS) support active");
  }
  if ((httpsClient != null) && !httpsClient.isHttps()) {
    throw new IllegalArgumentException("HTTPS client must have SSL (HTTPS) support active");
  }
  this.maxRedirects=MAX_REDIRECTS;
  this.client=client;
  this.httpsClient=httpsClient;
  ReentrantReadWriteLock rwLock=new ReentrantReadWriteLock();
  this.headerReadLock=rwLock.readLock();
  this.headerWriteLock=rwLock.writeLock();
  this.headers=new ArrayList<Map.Entry<String,String>>();
  this.handlers=new ConcurrentHashMap<Integer,ResponseCodeHandler>();
  this.addHandler(new AuthenticationResponseHandler());
  this.addHandler(new RedirectResponseHandler());
}
 

Example 84

From project httpClient, under directory /httpclient/src/main/java/org/apache/http/impl/client/.

Source file: StandardHttpRequestRetryHandler.java

  15 
vote

/** 
 * Default constructor
 */
public StandardHttpRequestRetryHandler(int retryCount,boolean requestSentRetryEnabled){
  super(retryCount,requestSentRetryEnabled);
  this.idempotentMethods=new ConcurrentHashMap<String,Boolean>();
  this.idempotentMethods.put("GET",Boolean.TRUE);
  this.idempotentMethods.put("HEAD",Boolean.TRUE);
  this.idempotentMethods.put("PUT",Boolean.TRUE);
  this.idempotentMethods.put("DELETE",Boolean.TRUE);
  this.idempotentMethods.put("OPTIONS",Boolean.TRUE);
  this.idempotentMethods.put("TRACE",Boolean.TRUE);
}
 

Example 85

From project httptunnel, under directory /src/main/java/com/yammer/httptunnel/server/.

Source file: HttpTunnelServerChannel.java

  15 
vote

protected HttpTunnelServerChannel(ChannelFactory factory,ChannelPipeline pipeline,ChannelSink sink,ServerSocketChannelFactory inboundFactory,ChannelGroup realConnections){
  super(factory,pipeline,sink);
  tunnelIdPrefix=Long.toHexString(random.nextLong());
  tunnels=new ConcurrentHashMap<String,HttpTunnelAcceptedChannel>();
  config=new HttpTunnelServerChannelConfig();
  realChannel=inboundFactory.newChannel(this.createRealPipeline(realConnections));
  config.setRealChannel(realChannel);
  opened=new AtomicBoolean(true);
  bindState=new AtomicReference<BindState>(BindState.UNBOUND);
  realConnections.add(realChannel);
  Channels.fireChannelOpen(this);
}
 

Example 86

From project indextank-engine, under directory /src/main/java/com/flaptor/indextank/index/.

Source file: BasicPromoter.java

  15 
vote

/** 
 * Constructor. Creates an empty Promoter.
 * @param backupDir the directory to wich the data stored in this Scorer shall be
 * @param load if true, the promoter is generated from it's serialized version.persisted.
 */
@SuppressWarnings("unchecked") public BasicPromoter(File backupDir,boolean load) throws IOException {
  checkDirArgument(backupDir);
  this.backupDir=backupDir;
  if (!load) {
    storage=new ConcurrentHashMap<String,String>();
  }
 else {
    File f=new File(this.backupDir,MAIN_FILE_NAME);
    ObjectInputStream is=null;
    try {
      is=new ObjectInputStream(new BufferedInputStream(new FileInputStream(f)));
      try {
        storage=(ConcurrentMap<String,String>)is.readObject();
      }
 catch (      ClassNotFoundException e) {
        throw new IllegalStateException(e);
      }
    }
  finally {
      Execute.close(is);
    }
  }
}
 

Example 87

From project IOCipherServer, under directory /src/javax/jmdns/impl/.

Source file: JmDNSImpl.java

  15 
vote

/** 
 * Create an instance of JmDNS and bind it to a specific network interface given its IP-address.
 * @param address IP address to bind to.
 * @param name name of the newly created JmDNS
 * @exception IOException
 */
public JmDNSImpl(InetAddress address,String name) throws IOException {
  super();
  if (logger.isLoggable(Level.FINER)) {
    logger.finer("JmDNS instance created");
  }
  _cache=new DNSCache(100);
  _listeners=Collections.synchronizedList(new ArrayList<DNSListener>());
  _serviceListeners=new ConcurrentHashMap<String,List<ServiceListenerStatus>>();
  _typeListeners=Collections.synchronizedSet(new HashSet<ServiceTypeListenerStatus>());
  _serviceCollectors=new ConcurrentHashMap<String,ServiceCollector>();
  _services=new ConcurrentHashMap<String,ServiceInfo>(20);
  _serviceTypes=new ConcurrentHashMap<String,ServiceTypeEntry>(20);
  _localHost=HostInfo.newHostInfo(address,this,name);
  _name=(name != null ? name : _localHost.getName());
  this.openMulticastSocket(this.getLocalHost());
  this.start(this.getServices().values());
  this.startReaper();
}