@Test public void testGetSession() throws TTException { assertTrue(mStorage.createResource(mResource)); ISession session = mStorage.getSession(new SessionConfiguration(mResource.mProperties .getProperty(ConstructorProps.RESOURCE), null)); assertEquals(0, session.getMostRecentVersion()); ISession sameSession = mStorage.getSession(new SessionConfiguration(mResource.mProperties .getProperty(ConstructorProps.RESOURCE), null)); assertEquals(session, sameSession); }
@Override public synchronized ISession getSession(final SessionConfiguration pSessionConf) throws TTException { final File resourceFile = new File(new File(mStorageConfig.mFile, StorageConfiguration.Paths.Data.getFile().getName()), pSessionConf.getResource()); Session returnVal = mSessions.get(pSessionConf.getResource()); if (returnVal == null) { checkState(resourceFile.exists(), "Resource could not be opened (since it was not created?) at location %s", resourceFile); ResourceConfiguration config = ResourceConfiguration.deserialize(mStorageConfig.mFile, pSessionConf.getResource()); config.mBackend.initialize(); final IBackendReader backendReader = config.mBackend.getReader(); UberBucket bucket = backendReader.readUber(); backendReader.close(); returnVal = new Session(this, config, pSessionConf, bucket); mSessions.put(pSessionConf.getResource(), returnVal); } return returnVal; }
Storage implements IStorage { @Override public synchronized ISession getSession(final SessionConfiguration pSessionConf) throws TTException { final File resourceFile = new File(new File(mStorageConfig.mFile, StorageConfiguration.Paths.Data.getFile().getName()), pSessionConf.getResource()); Session returnVal = mSessions.get(pSessionConf.getResource()); if (returnVal == null) { checkState(resourceFile.exists(), "Resource could not be opened (since it was not created?) at location %s", resourceFile); ResourceConfiguration config = ResourceConfiguration.deserialize(mStorageConfig.mFile, pSessionConf.getResource()); config.mBackend.initialize(); final IBackendReader backendReader = config.mBackend.getReader(); UberBucket bucket = backendReader.readUber(); backendReader.close(); returnVal = new Session(this, config, pSessionConf, bucket); mSessions.put(pSessionConf.getResource(), returnVal); } return returnVal; } }
Storage implements IStorage { @Override public synchronized ISession getSession(final SessionConfiguration pSessionConf) throws TTException { final File resourceFile = new File(new File(mStorageConfig.mFile, StorageConfiguration.Paths.Data.getFile().getName()), pSessionConf.getResource()); Session returnVal = mSessions.get(pSessionConf.getResource()); if (returnVal == null) { checkState(resourceFile.exists(), "Resource could not be opened (since it was not created?) at location %s", resourceFile); ResourceConfiguration config = ResourceConfiguration.deserialize(mStorageConfig.mFile, pSessionConf.getResource()); config.mBackend.initialize(); final IBackendReader backendReader = config.mBackend.getReader(); UberBucket bucket = backendReader.readUber(); backendReader.close(); returnVal = new Session(this, config, pSessionConf, bucket); mSessions.put(pSessionConf.getResource(), returnVal); } return returnVal; } private  Storage(final StorageConfiguration pStorageConf); }
Storage implements IStorage { @Override public synchronized ISession getSession(final SessionConfiguration pSessionConf) throws TTException { final File resourceFile = new File(new File(mStorageConfig.mFile, StorageConfiguration.Paths.Data.getFile().getName()), pSessionConf.getResource()); Session returnVal = mSessions.get(pSessionConf.getResource()); if (returnVal == null) { checkState(resourceFile.exists(), "Resource could not be opened (since it was not created?) at location %s", resourceFile); ResourceConfiguration config = ResourceConfiguration.deserialize(mStorageConfig.mFile, pSessionConf.getResource()); config.mBackend.initialize(); final IBackendReader backendReader = config.mBackend.getReader(); UberBucket bucket = backendReader.readUber(); backendReader.close(); returnVal = new Session(this, config, pSessionConf, bucket); mSessions.put(pSessionConf.getResource(), returnVal); } return returnVal; } private  Storage(final StorageConfiguration pStorageConf); static synchronized boolean createStorage(final StorageConfiguration pStorageConfig); static synchronized void truncateStorage(final StorageConfiguration pConf); static synchronized boolean existsStorage(final File pStoragePath); @Override synchronized boolean createResource(final ResourceConfiguration pResConf); @Override synchronized boolean truncateResource(final SessionConfiguration pSesConf); static synchronized IStorage openStorage(final File pFile); @Override synchronized ISession getSession(final SessionConfiguration pSessionConf); @Override synchronized boolean close(); @Override boolean existsResource(String pResourceName); @Override String[] listResources(); @Override File getLocation(); @Override String toString(); }
Storage implements IStorage { @Override public synchronized ISession getSession(final SessionConfiguration pSessionConf) throws TTException { final File resourceFile = new File(new File(mStorageConfig.mFile, StorageConfiguration.Paths.Data.getFile().getName()), pSessionConf.getResource()); Session returnVal = mSessions.get(pSessionConf.getResource()); if (returnVal == null) { checkState(resourceFile.exists(), "Resource could not be opened (since it was not created?) at location %s", resourceFile); ResourceConfiguration config = ResourceConfiguration.deserialize(mStorageConfig.mFile, pSessionConf.getResource()); config.mBackend.initialize(); final IBackendReader backendReader = config.mBackend.getReader(); UberBucket bucket = backendReader.readUber(); backendReader.close(); returnVal = new Session(this, config, pSessionConf, bucket); mSessions.put(pSessionConf.getResource(), returnVal); } return returnVal; } private  Storage(final StorageConfiguration pStorageConf); static synchronized boolean createStorage(final StorageConfiguration pStorageConfig); static synchronized void truncateStorage(final StorageConfiguration pConf); static synchronized boolean existsStorage(final File pStoragePath); @Override synchronized boolean createResource(final ResourceConfiguration pResConf); @Override synchronized boolean truncateResource(final SessionConfiguration pSesConf); static synchronized IStorage openStorage(final File pFile); @Override synchronized ISession getSession(final SessionConfiguration pSessionConf); @Override synchronized boolean close(); @Override boolean existsResource(String pResourceName); @Override String[] listResources(); @Override File getLocation(); @Override String toString();  }