Changeset 5682
- Timestamp:
- 10/13/08 14:03:05 (7 weeks ago)
- Location:
- trunk
- Files:
-
- 13 modified
-
SRC/org/openmicroscopy/shoola/agents/events/iviewer/ViewImage.java (modified) (3 diffs)
-
SRC/org/openmicroscopy/shoola/agents/imviewer/ImViewerAgent.java (modified) (1 diff)
-
SRC/org/openmicroscopy/shoola/agents/imviewer/view/ImViewer.java (modified) (2 diffs)
-
SRC/org/openmicroscopy/shoola/agents/imviewer/view/ImViewerComponent.java (modified) (2 diffs)
-
SRC/org/openmicroscopy/shoola/agents/imviewer/view/ImViewerModel.java (modified) (3 diffs)
-
SRC/org/openmicroscopy/shoola/env/cache/CacheService.java (modified) (3 diffs)
-
SRC/org/openmicroscopy/shoola/env/cache/CacheServiceFactory.java (modified) (1 diff)
-
SRC/org/openmicroscopy/shoola/env/cache/CacheServiceImpl.java (modified) (5 diffs)
-
SRC/org/openmicroscopy/shoola/env/data/OMEROGateway.java (modified) (6 diffs)
-
SRC/org/openmicroscopy/shoola/env/rnd/PixelsServicesFactory.java (modified) (13 diffs)
-
SRC/org/openmicroscopy/shoola/env/rnd/RenderingControlProxy.java (modified) (7 diffs)
-
SRC/org/openmicroscopy/shoola/env/rnd/data/DataSink.java (modified) (7 diffs)
-
TEST/org/openmicroscopy/shoola/env/cache/NullCacheService.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/org/openmicroscopy/shoola/agents/events/iviewer/ViewImage.java
r5509 r5682 36 36 import org.openmicroscopy.shoola.env.rnd.RndProxyDef; 37 37 38 import pojos.DataObject; 38 39 import pojos.ImageData; 39 40 … … 69 70 private long selectedUserID; 70 71 72 /** The parent of the image or <code>null</code> if no context specified. */ 73 private DataObject parent; 74 75 /** 76 * The grandparent of the image or <code>null</code> if no 77 * context specified. 78 */ 79 private DataObject grandParent; 80 71 81 /** 72 82 * Creates a new instance. … … 83 93 selectedUserID = -1; 84 94 } 95 96 /** 97 * Sets the context of the node. 98 * 99 * @param parent The parent of the image or <code>null</code> 100 * if no context specified. 101 * @param grandParent The grandparent of the image or <code>null</code> 102 * if no context specified. 103 */ 104 public void setContext(DataObject parent, DataObject grandParent) 105 { 106 this.parent = parent; 107 this.grandParent = grandParent; 108 } 109 110 /** 111 * Returns the parent of the image or <code>null</code> 112 * if no context specified. 113 * 114 * @return See above. 115 */ 116 public DataObject getParent() { return parent; } 117 118 /** 119 * Returns the grandparent of the image or <code>null</code> 120 * if no context specified. 121 * 122 * @return See above. 123 */ 124 public DataObject getGrandParent() { return grandParent; } 85 125 86 126 /** -
trunk/SRC/org/openmicroscopy/shoola/agents/imviewer/ImViewerAgent.java
r5509 r5682 108 108 ImViewer view = ImViewerFactory.getImageViewer(evt.getImage(), 109 109 evt.getRequesterBounds()); 110 if (view != null) 110 if (view != null) { 111 111 view.activate(evt.getSettings(), evt.getSelectedUserID()); 112 view.setContext(evt.getParent(), evt.getGrandParent()); 113 } 112 114 } 113 115 -
trunk/SRC/org/openmicroscopy/shoola/agents/imviewer/view/ImViewer.java
r5641 r5682 46 46 import org.openmicroscopy.shoola.env.rnd.RndProxyDef; 47 47 import org.openmicroscopy.shoola.util.ui.component.ObservableComponent; 48 49 import pojos.DataObject; 48 50 import pojos.ExperimenterData; 49 51 import pojos.ImageData; … … 901 903 public void setProjectedRenderingSettings(Boolean result, ImageData image); 902 904 905 /** 906 * Sets the context of the node. 907 * 908 * @param parent The parent of the image or <code>null</code> 909 * if no context specified. 910 * @param grandParent The grandparent of the image or <code>null</code> 911 * if no context specified. 912 */ 913 public void setContext(DataObject parent, DataObject grandParent); 914 903 915 } -
trunk/SRC/org/openmicroscopy/shoola/agents/imviewer/view/ImViewerComponent.java
r5630 r5682 82 82 import org.openmicroscopy.shoola.util.ui.UIUtilities; 83 83 import org.openmicroscopy.shoola.util.ui.component.AbstractComponent; 84 85 import pojos.DataObject; 84 86 import pojos.ExperimenterData; 85 87 import pojos.ImageData; … … 2586 2588 } 2587 2589 2590 /** 2591 * Sets the context of the node. 2592 * 2593 * @param parent The parent of the image or <code>null</code> 2594 * if no context specified. 2595 * @param grandParent The grandparent of the image or <code>null</code> 2596 * if no context specified. 2597 */ 2598 public void setContext(DataObject parent, DataObject grandParent) 2599 { 2600 if (model.getState() == DISCARDED) return; 2601 model.setContext(parent, grandParent); 2602 } 2603 2588 2604 } -
trunk/SRC/org/openmicroscopy/shoola/agents/imviewer/view/ImViewerModel.java
r5657 r5682 69 69 import org.openmicroscopy.shoola.env.rnd.RndProxyDef; 70 70 import org.openmicroscopy.shoola.util.image.geom.Factory; 71 72 import pojos.DataObject; 71 73 import pojos.ExperimenterData; 72 74 import pojos.ImageData; … … 228 230 private boolean initMagnificationFactor; 229 231 232 /** The parent of the image or <code>null</code> if no context specified. */ 233 private DataObject parent; 234 235 /** 236 * The grandparent of the image or <code>null</code> if no 237 * context specified. 238 */ 239 private DataObject grandParent; 240 230 241 /** Computes the values of the {@link #sizeX} and {@link #sizeY} fields. */ 231 242 private void computeSizes() … … 1431 1442 } 1432 1443 1444 /** 1445 * Sets the context of the node. 1446 * 1447 * @param parent The parent of the image or <code>null</code> 1448 * if no context specified. 1449 * @param grandParent The grandparent of the image or <code>null</code> 1450 * if no context specified. 1451 */ 1452 void setContext(DataObject parent, DataObject grandParent) 1453 { 1454 this.parent = parent; 1455 this.grandParent = grandParent; 1456 } 1457 1458 /** 1459 * Returns the parent of the image or <code>null</code> 1460 * if no context specified. 1461 * 1462 * @return See above. 1463 */ 1464 DataObject getParent() { return parent; } 1465 1466 /** 1467 * Returns the grandparent of the image or <code>null</code> 1468 * if no context specified. 1469 * 1470 * @return See above. 1471 */ 1472 DataObject getGrandParent() { return grandParent; } 1473 1474 1433 1475 } -
trunk/SRC/org/openmicroscopy/shoola/env/cache/CacheService.java
r5574 r5682 52 52 53 53 /** Indicates to cache data in memory only. */ 54 public static final int IN_MEMORY_ONLY = 2; 54 public static final int IN_MEMORY = 2; 55 56 /** The default size of a cache. */ 57 public static final int CACHE_SIZE = 10; 55 58 56 59 /** … … 62 65 */ 63 66 public int createCache(); 67 68 /** 69 * Creates a cache of a given type. 70 * 71 * @param type The type of cache to create. 72 * @param size The size of the cache. 73 * @return See above. 74 * @throws CacheServiceException Thrown if an error occured while 75 * creating the cache. 76 */ 77 public int createCache(int type, int size); 64 78 65 79 /** … … 109 123 public void clearCache(int cacheID); 110 124 125 /** 126 * Resets the size (number of items in memory) of the cache, 127 * when a new cache is created or deleted. 128 * 129 * @param cacheID The id of the cache. 130 * @param size The size of the cache. 131 */ 132 public void setCacheSize(int cacheID, int size); 133 111 134 } -
trunk/SRC/org/openmicroscopy/shoola/env/cache/CacheServiceFactory.java
r5574 r5682 111 111 public int createCache() { return -1; } 112 112 public int createCache(int type) { return -1; } 113 public int createCache(int type, int size) { return -1; } 113 114 public Object getElement(int cacheID, Object key) { return null; } 114 115 public void removeCache(int cacheID) {} 115 116 public void clearCache(int cacheID) {} 117 public void setCacheSize(int cacheID, int size) {} 116 118 }; 117 119 } -
trunk/SRC/org/openmicroscopy/shoola/env/cache/CacheServiceImpl.java
r5574 r5682 51 51 implements CacheService 52 52 { 53 53 54 54 /** Reference to the manager. */ 55 55 private CacheManager manager; … … 87 87 /** 88 88 * Implemented as specified by {@link CacheService}. 89 * @see CacheService#createCache(int )89 * @see CacheService#createCache(int, int) 90 90 */ 91 public int createCache(int type )91 public int createCache(int type, int size) 92 92 { 93 93 Cache cache; 94 if (size < 0) size = 0; 94 95 switch (type) { 95 96 case PERSISTENCE_ON_DISK: 97 //TODO: implement. 96 98 return -1; 97 case IN_MEMORY _ONLY:99 case IN_MEMORY: 98 100 cacheID++; 99 cache = new Cache(""+cacheID, 10000, false, false, 300, 600); 101 //name, maximum number of elements, overflow to disk, eternal 102 //time to Idle, time to live 103 cache = new Cache(""+cacheID, size, true, false, 300, 600); 100 104 manager.addCache(cache); 101 105 break; … … 108 112 } 109 113 return cacheID; 114 115 } 116 117 /** 118 * Implemented as specified by {@link CacheService}. 119 * @see CacheService#createCache(int) 120 */ 121 public int createCache(int type) 122 { 123 return createCache(type, CACHE_SIZE); 110 124 } 111 125 … … 128 142 Cache cache = manager.getCache(""+cacheID); 129 143 if (cache == null) return; 144 if (cache.getSize() >= 145 cache.getCacheConfiguration().getMaxElementsInMemory()) 146 cache.flush(); 130 147 cache.put(new Element(key, element)); 131 148 } … … 155 172 } 156 173 174 /** 175 * Implemented as specified by {@link CacheService}. 176 * @see CacheService#setCacheSize(int, int) 177 */ 178 public void setCacheSize(int cacheID, int size) 179 { 180 Cache cache = manager.getCache(""+cacheID); 181 if (cache == null) return; 182 cache.flush(); 183 cache.getCacheConfiguration().setMaxElementsInMemory(size); 184 185 } 186 157 187 } -
trunk/SRC/org/openmicroscopy/shoola/env/data/OMEROGateway.java
r5672 r5682 48 48 49 49 //Application-internal dependencies 50 import org.openmicroscopy.shoola.env.LookupNames;51 50 import org.openmicroscopy.shoola.env.data.util.PojoMapper; 52 51 import org.openmicroscopy.shoola.env.data.util.SearchDataContext; 53 52 import org.openmicroscopy.shoola.env.rnd.RenderingServiceException; 54 53 import ome.system.UpgradeCheck; 54 import omero.AuthenticationException; 55 import omero.DataAccessException; 56 import omero.ExpiredCredentialException; 55 57 import omero.InternalException; 56 58 import omero.RInt; … … 59 61 import omero.RTime; 60 62 import omero.RType; 63 import omero.SecurityViolation; 61 64 import omero.ServerError; 65 import omero.SessionException; 62 66 import omero.client; 63 67 import omero.api.IAdminPrx; … … 223 227 private float compression; 224 228 225 //Blitz stuff226 /** Tell us to configure ice. */227 private Properties iceConfig;228 229 229 /** The port to connect. */ 230 230 private int port; … … 255 255 { 256 256 Throwable cause = t.getCause(); 257 if (cause instanceof ServerError) { 258 259 260 String s = "Cannot access data for security reasons \n"; 257 if (cause instanceof DataAccessException) { 258 String s = "Cannot access data. \n"; 261 259 throw new DSAccessException(s+message, t); 262 } 260 } else if (cause instanceof SecurityViolation) { 261 String s = "For security reasons, cannot access data. \n"; 262 throw new DSAccessException(s+message, t); 263 } else if (cause instanceof SessionException) { 264 String s = "Session is not valid. \n"; 265 throw new DSOutOfServiceException(s+message, t); 266 } else if (cause instanceof AuthenticationException) { 267 String s = "Cannot initialize the session. \n"; 268 throw new DSOutOfServiceException(s+message, t); 269 } else if (cause instanceof ExpiredCredentialException) { 270 String s = "Cannot initialize the session. \n"; 271 throw new DSOutOfServiceException(s+message, t); 272 } 273 throw new DSAccessException("Cannot access data. \n"+message, t); 263 274 } 264 275 … … 839 850 return false; 840 851 } 841 852 842 853 /** 843 854 * Creates a new instance. 844 855 * 845 * @param iceConfig The Ice configuration. 846 * @param dsFactory A reference to the factory. Used whenever a broken 847 * link is detected to get the Login Service and try 848 * reestablishing a valid link to <i>OMEDS</i>. 849 * Mustn't be <code>null</code>. 850 */ 851 OMEROGateway(Properties iceConfig, DataServicesFactory dsFactory) 852 { 853 if (dsFactory == null) 854 throw new IllegalArgumentException("No Data service factory."); 855 this.dsFactory = dsFactory; 856 this.iceConfig = iceConfig; 857 thumbRetrieval = 0; 858 } 859 860 /** 861 * Creates a new instance. 862 * 863 * @param iceConfig The Ice configuration. 856 * @param port The port used to connect. 864 857 * @param dsFactory A reference to the factory. Used whenever a broken 865 858 * link is detected to get the Login Service and try … … 1027 1020 try { 1028 1021 compression = compressionLevel; 1029 1030 //Put value of hostname1031 /*1032 Set keys = iceConfig.keySet();1033 Iterator i = keys.iterator();1034 String key, value;1035 while (i.hasNext()) {1036 key = (String) i.next();1037 value = iceConfig.getProperty(key);1038 value = value.replaceAll(LookupNames.ICE_HOSTNAME, hostName);1039 iceConfig.put(key, value);1040 }1041 blitzClient = new client(iceConfig);1042 */1043 1022 this.hostName = hostName; 1044 1023 if (port > 0) blitzClient = new client(hostName, port); -
trunk/SRC/org/openmicroscopy/shoola/env/rnd/PixelsServicesFactory.java
r5674 r5682 27 27 //Java imports 28 28 import java.awt.image.BufferedImage; 29 import java.lang.management.ManagementFactory; 30 import java.lang.management.MemoryUsage; 29 31 import java.util.Collection; 30 32 import java.util.HashMap; … … 48 50 import org.openmicroscopy.shoola.env.data.DSOutOfServiceException; 49 51 import org.openmicroscopy.shoola.env.rnd.data.DataSink; 50 import org.openmicroscopy.shoola.env.rnd.roi.ROIAnalyser;51 52 52 import pojos.PixelsData; 53 53 … … 73 73 { 74 74 75 /** The percentage of memory used for caching. */ 76 private static final double RATIO = 0.10; 77 78 /** Values used to determine the size of a cache. */ 79 private static final int FACTOR = 1024*1024; 80 75 81 /** The sole instance. */ 76 82 private static PixelsServicesFactory singleton; … … 79 85 private static Registry registry; 80 86 87 /** The maximum amount of memory in bytes used for caching. */ 88 private static int maxSize; 89 81 90 /** 82 91 * Converts the {@link RenderingDef} into a {@link RndProxyDef}. … … 149 158 registry = c.getRegistry(); 150 159 singleton = new PixelsServicesFactory(); 160 //Retrieve the maximum heap size. 161 MemoryUsage usage = 162 ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); 163 String message = "Heap memory usage: max "+usage.getMax(); 164 registry.getLogger().info(singleton, message); 165 //percentage of memory used for caching. 166 maxSize = (int) (RATIO*usage.getMax())/FACTOR; 151 167 } 152 168 return singleton; … … 234 250 singleton.rndSvcProxies.get(new Long(pixelsID)); 235 251 if (proxy != null) { 236 proxy.shutDown();237 252 proxy.resetRenderingEngine(re, convert(def)); 238 253 } … … 259 274 proxy.shutDown(); 260 275 singleton.rndSvcProxies.remove(new Long(pixelsID)); 276 getCacheSize(); 261 277 } 262 278 } … … 312 328 singleton.pixelsSource.isSame(pixels.getId())) 313 329 return singleton.pixelsSource; 314 singleton.pixelsSource = DataSink.makeNew(pixels, registry); 330 int size = getCacheSize(); 331 boolean cacheInMemory = true; 332 if (size <= 0) cacheInMemory = false; 333 singleton.pixelsSource = DataSink.makeNew(pixels, registry, 334 cacheInMemory); 315 335 return singleton.pixelsSource; 316 336 } … … 329 349 throw new IllegalArgumentException("Not allow to access method."); 330 350 if (singleton.pixelsSource != null && 331 singleton.pixelsSource.isSame(pixelsID)) 332 singleton.pixelsSource.eraseCache(); 351 singleton.pixelsSource.isSame(pixelsID)) { 352 int size = getCacheSize(); 353 boolean cacheInMemory = true; 354 if (size <= 0) cacheInMemory = false; 355 singleton.pixelsSource.clearCache(); 356 singleton.pixelsSource.setCacheInMemory(cacheInMemory); 357 } 333 358 } 334 359 … … 342 367 * @param pDef The plane to render. 343 368 * @return See above. 369 * 370 * @throws RenderingServiceException If an error occured while setting 371 * the value. 372 * @throws DSOutOfServiceException If the connection is broken. 344 373 */ 345 374 public static BufferedImage render(Registry context, Long pixelsID, 346 375 PlaneDef pDef) 376 throws RenderingServiceException, DSOutOfServiceException 347 377 { 348 378 if (!(context.equals(registry))) … … 353 383 throw new RuntimeException("No rendering service " + 354 384 &nbs
