Wednesday, August 20, 2014

Two threads in a synchronized block at the same time .

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.hello;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author gagandsi
 */
public class Hello {
    
    
    public   synchronized void method( String s){
        if (s.equals("1")){
            try {
                System.out.println("this : " + this + " : "+ s);
                Thread.currentThread().yield();
                this.wait(1000);
                System.out.println("This is " + s + " again");
            } catch (InterruptedException ex) {
                Logger.getLogger(Hello.class.getName()).log(Level.SEVERE, null, ex);
            }
        }else {
            System.out.println("This is  " + s);
        }
    }
    

    public static void main(String[] args) {
        try {
            Hello one = new Hello();
            Thread t = new Thread(){

                @Override
                public void run() {
                    super.run(); 
                    one.method("1");
                }
            
        } ;
            
            Thread t2 = new Thread(){

                @Override
                public void run() {
                    super.run(); 
                    one.method("2");
                }
            
        } ;
            t.start();
            t2.start();
        } finally {
        }

    }
}

Wednesday, August 13, 2014

Simple countdownlatch with callable example

 package com.cisco.my;  
 import java.util.ArrayList;  
 import java.util.concurrent.Callable;  
 import java.util.concurrent.CountDownLatch;  
 import java.util.concurrent.ExecutorService;  
 import java.util.concurrent.Executors;  
 import java.util.concurrent.Future;  
 class MyJob implements Callable<String> {  
      CountDownLatch latch;  
      String threadName;  
      String job;  
      public MyJob(CountDownLatch latch, String threadName, String job) {  
           super();  
           this.latch = latch;  
           this.threadName = threadName;  
           this.job = job;  
      }  
      @Override  
      public String call() throws Exception {  
           // TODO Auto-generated method stub  
           System.out.println(threadName + " Going to sleep");  
           Thread.sleep(5000);  
           System.out.println(threadName + " Awake to sleep");  
           latch.countDown();  
           return job.split(" ")[0];  
      }  
 }  
 public class CountdownLatchExample {  
      private static CountDownLatch latch = new CountDownLatch(10);  
      public static void main(String[] args) {  
           ExecutorService service = Executors.newFixedThreadPool(10);  
           ArrayList<Future<String>> x = new ArrayList<Future<String>>();  
           for (int i = 0; i < 10; i++) {  
                Future<String> fut = service.submit(new MyJob(latch, "Thread " + i,  
                          "Random String to process"));  
                x.add(fut);  
           }  
           try {  
                latch.await();  
           } catch (InterruptedException e) {  
                e.printStackTrace();  
           }  
      }  
 }  

Friday, August 8, 2014

org.neo4j.kernel.impl.nioneo.store.UnderlyingStorageException: Unable to load position[25] @[625]


I was getting the following exception in my neo4j code.


org.neo4j.kernel.impl.nioneo.store.UnderlyingStorageException: Unable to load position[25] @[625]
at org.neo4j.kernel.impl.nioneo.store.PersistenceRow.readFullWindow(PersistenceRow.java:162) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.store.PersistenceRow$State$1.transition(PersistenceRow.java:114) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.store.PersistenceRow.lock(PersistenceRow.java:58) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.store.PersistenceWindowPool.acquire(PersistenceWindowPool.java:197) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.store.CommonAbstractStore.acquireWindow(CommonAbstractStore.java:436) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.store.RelationshipGroupStore.getRecord(RelationshipGroupStore.java:58) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.xa.Loaders$4.load(Loaders.java:166) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.xa.Loaders$4.load(Loaders.java:156) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.xa.RecordChanges.getOrLoad(RecordChanges.java:64) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.xa.RecordChanges.getOrLoad(RecordChanges.java:41) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.xa.RelationshipGroupGetter.getRelationshipGroup(RelationshipGroupGetter.java:45) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.xa.RelationshipGroupGetter.getOrCreateRelationshipGroup(RelationshipGroupGetter.java:67) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.xa.RelationshipCreator.connectRelationshipToDenseNode(RelationshipCreator.java:176) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.xa.RelationshipCreator.connectRelationship(RelationshipCreator.java:159) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.xa.RelationshipCreator.relationshipCreate(RelationshipCreator.java:88) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.xa.NeoStoreTransactionContext.relationshipCreate(NeoStoreTransactionContext.java:89) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.nioneo.xa.NeoStoreTransaction.relationshipCreate(NeoStoreTransaction.java:827) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.api.StateHandlingStatementOperations.relationshipCreate(StateHandlingStatementOperations.java:115) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.api.ConstraintEnforcingEntityOperations.relationshipCreate(ConstraintEnforcingEntityOperations.java:153) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.api.LockingStatementOperations.relationshipCreate(LockingStatementOperations.java:216) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.api.OperationsFacade.relationshipCreate(OperationsFacade.java:515) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.kernel.impl.core.NodeProxy.createRelationshipTo(NodeProxy.java:455) ~[neo4j-kernel-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.spi.v2_1.TransactionBoundQueryContext.createRelationship(TransactionBoundQueryContext.scala:100) ~[neo4j-cypher-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.spi.DelegatingQueryContext.createRelationship(DelegatingQueryContext.scala:45) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.org$neo4j$cypher$internal$compiler$v2_1$spi$ExceptionTranslatingQueryContext$$super$createRelationship(ExceptionTranslatingQueryContext.scala:41) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$createRelationship$1.apply(ExceptionTranslatingQueryContext.scala:41) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$createRelationship$1.apply(ExceptionTranslatingQueryContext.scala:41) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.org$neo4j$cypher$internal$compiler$v2_1$spi$ExceptionTranslatingQueryContext$$translateException(ExceptionTranslatingQueryContext.scala:149) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.createRelationship(ExceptionTranslatingQueryContext.scala:41) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.spi.UpdateCountingQueryContext.createRelationship(UpdateCountingQueryContext.scala:73) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.mutation.CreateRelationship.exec(CreateRelationship.scala:77) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.mutation.MergePatternAction$$anonfun$1.apply(MergePatternAction.scala:78) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.mutation.MergePatternAction$$anonfun$1.apply(MergePatternAction.scala:77) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111) ~[scala-library-2.10.4.jar:na]
at scala.collection.immutable.List.foldLeft(List.scala:84) ~[scala-library-2.10.4.jar:na]
at org.neo4j.cypher.internal.compiler.v2_1.mutation.MergePatternAction.createThePattern(MergePatternAction.scala:77) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.mutation.MergePatternAction.exec(MergePatternAction.scala:57) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.pipes.ExecuteUpdateCommandsPipe.org$neo4j$cypher$internal$compiler$v2_1$pipes$ExecuteUpdateCommandsPipe$$exec(ExecuteUpdateCommandsPipe.scala:55) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.pipes.ExecuteUpdateCommandsPi$$$$1019fdff8b266d7d9d5647386930b3d8$$$$ands$1$$anonfun$apply$2.apply(ExecuteUpdateCommandsPipe.scala:44) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.pipes.ExecuteUpdateCommandsPi$$$$1019fdff8b266d7d9d5647386930b3d8$$$$ands$1$$anonfun$apply$2.apply(ExecuteUpdateCommandsPipe.scala:44) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371) ~[scala-library-2.10.4.jar:na]
at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371) ~[scala-library-2.10.4.jar:na]
at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) ~[scala-library-2.10.4.jar:na]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$hasNext$1.apply$mcZ$sp(ClosingIterator.scala:37) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:34) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:34) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$failIfThrows$1.apply(ClosingIterator.scala:93) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.decoratedCypherException(ClosingIterator.scala:102) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.failIfThrows(ClosingIterator.scala:91) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.hasNext(ClosingIterator.scala:34) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at scala.collection.Iterator$class.foreach(Iterator.scala:727) ~[scala-library-2.10.4.jar:na]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.foreach(ClosingIterator.scala:28) ~[neo4j-cypher-compiler-2.1-2.1.2.jar:2.1.2]
at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48) ~[scala-library-2.10.4.jar:na]
at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176) ~[scala-library-2.10.4.jar:na]
at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45) ~[scala-library-2.10.4.jar:na]

Friday, August 1, 2014

Chrome Extension location

~/Library/Application Support/Google/Chrome/Default/Extensions