• R/O
  • SSH
  • HTTPS

okuyama: 提交


Commit MetaInfo

修訂907 (tree)
時間2012-02-09 01:54:38
作者okuyamaoo

Log Message

シンクロ周りをputとバックグランド書き出しまわりで調整

Change Summary

差異

--- trunk/src/okuyama/imdst/util/io/HighSpeedDiskCacheRandomAccess.java (revision 906)
+++ trunk/src/okuyama/imdst/util/io/HighSpeedDiskCacheRandomAccess.java (revision 907)
@@ -79,7 +79,7 @@
7979 for (int i = 0; i < data.length; i++) {
8080 cacheData[i] = data[i];
8181 }
82- this.diskCacheManager.addCacheDarta(seekPoint, cacheData);
82+ this.diskCacheManager.addCacheData(seekPoint, cacheData);
8383 } else {
8484 //cacheHitCount++;
8585 //if ((cacheHitCount % 5000) == 0) System.out.println("Cache hit count=" + cacheHitCount + " [" + new Date().toString());
@@ -110,6 +110,7 @@
110110 private ConcurrentHashMap fixWriteDataMap = new ConcurrentHashMap(20000);
111111 private DiskBaseCacheMap diskBaseCacheMap = null;
112112 private Object sync = new Object();
113+ private Object removeSync = new Object();
113114
114115 private boolean noCache = false;
115116
@@ -149,6 +150,10 @@
149150 Long cacheSeekPoint = (Long)this.writeQueue.poll();
150151 if (cacheSeekPoint != null) {
151152 byte[] cacheData = (byte[])fixWriteDataMap.remove(cacheSeekPoint);
153+ if (cacheData == null) {
154+ Thread.sleep(10);
155+ cacheData = (byte[])fixWriteDataMap.remove(cacheSeekPoint);
156+ }
152157 if (cacheData != null) {
153158 this.diskBaseCacheMap.put(cacheSeekPoint, cacheData);
154159 }
@@ -165,9 +170,9 @@
165170 }
166171
167172
168- public void addCacheDarta(long seekPoint, byte[] cacheData) {
173+ public void addCacheData(long seekPoint, byte[] cacheData) {
169174 if (this.noCache) return;
170- synchronized (this.sync) {
175+ synchronized (this.removeSync) {
171176 Long seekPointLong = new Long(seekPoint);
172177 if(this.writeQueue.offer(seekPointLong)) {
173178 this.fixWriteDataMap.put(seekPointLong, cacheData);
@@ -183,9 +188,12 @@
183188
184189 public void removeCache(long seekPoint) {
185190 if (this.noCache) return;
186- synchronized (this.sync) {
187- this.diskBaseCacheMap.remove(new Long(seekPoint));
188- this.fixWriteDataMap.remove(seekPoint);
191+ synchronized (this.removeSync) {
192+ synchronized (this.sync) {
193+
194+ this.diskBaseCacheMap.remove(new Long(seekPoint));
195+ this.fixWriteDataMap.remove(seekPoint);
196+ }
189197 }
190198 }
191199
Show on old repository browser