Issue #229 moving caches into the caveData directory
Change-Id: I3d502ef858939738adf1835d2292f55e2b3edc44 Former-commit-id: a499df61044947aaf40ac118e1476f41736419b0
This commit is contained in:
parent
13a99abe7b
commit
b3da2a3429
3 changed files with 15 additions and 2 deletions
|
@ -230,12 +230,17 @@ public class CachingDataStore implements IDataStore {
|
||||||
long t0 = System.currentTimeMillis();
|
long t0 = System.currentTimeMillis();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
try {
|
try {
|
||||||
|
if (!file.getParentFile().exists()) {
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
FileOutputStream fout = new FileOutputStream(file);
|
FileOutputStream fout = new FileOutputStream(file);
|
||||||
DynamicSerializationManager
|
DynamicSerializationManager
|
||||||
.getManager(SerializationType.Thrift).serialize(result,
|
.getManager(SerializationType.Thrift).serialize(result,
|
||||||
fout);
|
fout);
|
||||||
fout.close();
|
fout.close();
|
||||||
LRUCacheFS.poll(file);
|
LRUCacheFS.poll(file);
|
||||||
|
file.setReadable(true, false);
|
||||||
|
file.setWritable(true, false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Error storing object to file: "
|
System.err.println("Error storing object to file: "
|
||||||
+ e.getLocalizedMessage());
|
+ e.getLocalizedMessage());
|
||||||
|
|
|
@ -63,6 +63,9 @@ public class ThinClientCacheManager implements IPropertyChangeListener {
|
||||||
// We'll always store the cache data to the file system
|
// We'll always store the cache data to the file system
|
||||||
long t0 = System.currentTimeMillis();
|
long t0 = System.currentTimeMillis();
|
||||||
File thinClientCacheDir = this.thinClientCacheDir;
|
File thinClientCacheDir = this.thinClientCacheDir;
|
||||||
|
if (!thinClientCacheDir.exists()) {
|
||||||
|
thinClientCacheDir.mkdirs();
|
||||||
|
}
|
||||||
for (AbstractCachePersistance persistance : persistors) {
|
for (AbstractCachePersistance persistance : persistors) {
|
||||||
String fileName = persistance.getFileName();
|
String fileName = persistance.getFileName();
|
||||||
File cacheFile = new File(thinClientCacheDir, fileName);
|
File cacheFile = new File(thinClientCacheDir, fileName);
|
||||||
|
@ -71,6 +74,8 @@ public class ThinClientCacheManager implements IPropertyChangeListener {
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
cacheFile.setReadable(true, false);
|
||||||
|
cacheFile.setWritable(true, false);
|
||||||
}
|
}
|
||||||
System.out.println("Time to store thin client caches: "
|
System.out.println("Time to store thin client caches: "
|
||||||
+ (System.currentTimeMillis() - t0) + "ms");
|
+ (System.currentTimeMillis() - t0) + "ms");
|
||||||
|
|
|
@ -19,9 +19,12 @@
|
||||||
**/
|
**/
|
||||||
package com.raytheon.uf.viz.thinclient.preferences;
|
package com.raytheon.uf.viz.thinclient.preferences;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
|
||||||
|
import com.raytheon.uf.viz.core.localization.LocalizationManager;
|
||||||
import com.raytheon.uf.viz.thinclient.Activator;
|
import com.raytheon.uf.viz.thinclient.Activator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,8 +56,8 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
|
||||||
public void initializeDefaultPreferences() {
|
public void initializeDefaultPreferences() {
|
||||||
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
|
||||||
// Set Defaults for cache directory and cache settings
|
// Set Defaults for cache directory and cache settings
|
||||||
store.setDefault(ThinClientPreferenceConstants.P_CACHE_DIR,
|
store.setDefault(ThinClientPreferenceConstants.P_CACHE_DIR, new File(
|
||||||
System.getProperty("java.io.tmpdir", ""));
|
LocalizationManager.getUserDir(), "cache").getAbsolutePath());
|
||||||
store.setDefault(ThinClientPreferenceConstants.P_CACHE_WEATHER, true);
|
store.setDefault(ThinClientPreferenceConstants.P_CACHE_WEATHER, true);
|
||||||
store.setDefault(ThinClientPreferenceConstants.P_CACHE_LOCALIZATION,
|
store.setDefault(ThinClientPreferenceConstants.P_CACHE_LOCALIZATION,
|
||||||
true);
|
true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue