@Test public void testMultipleThread() throws InterruptedException { final IStorage[] s = new IStorage[2]; Thread t = new Thread(new Runnable() { @Override public void run() { s[0] = StorageFactory.storage(new MockupStorageAware()); } }); t.start(); t.join(); t = new Thread(new Runnable() { @Override public void run() { s[1] = StorageFactory.storage(new MockupStorageAware()); } }); t.start(); t.join(); Assert.assertNotSame(s[0], s[1]); }
public static IStorage storage(IStorageAware aware) { if (configuredUseLocalStorage != null) { return configuredUseLocalStorage; } ImplementationSwitch<IStorage> current = storages.get(); if (storages.get() == null) { current = new ImplementationSwitch<>(KylinConfig.getInstanceFromEnv().getStorageEngines(), IStorage.class); storages.set(current); } return current.get(aware.getStorageType()); }
StorageFactory { public static IStorage storage(IStorageAware aware) { if (configuredUseLocalStorage != null) { return configuredUseLocalStorage; } ImplementationSwitch<IStorage> current = storages.get(); if (storages.get() == null) { current = new ImplementationSwitch<>(KylinConfig.getInstanceFromEnv().getStorageEngines(), IStorage.class); storages.set(current); } return current.get(aware.getStorageType()); } }
StorageFactory { public static IStorage storage(IStorageAware aware) { if (configuredUseLocalStorage != null) { return configuredUseLocalStorage; } ImplementationSwitch<IStorage> current = storages.get(); if (storages.get() == null) { current = new ImplementationSwitch<>(KylinConfig.getInstanceFromEnv().getStorageEngines(), IStorage.class); storages.set(current); } return current.get(aware.getStorageType()); }  }
StorageFactory { public static IStorage storage(IStorageAware aware) { if (configuredUseLocalStorage != null) { return configuredUseLocalStorage; } ImplementationSwitch<IStorage> current = storages.get(); if (storages.get() == null) { current = new ImplementationSwitch<>(KylinConfig.getInstanceFromEnv().getStorageEngines(), IStorage.class); storages.set(current); } return current.get(aware.getStorageType()); }  static IStorage storage(IStorageAware aware); static void clearCache(); static IStorageQuery createQuery(IRealization realization); static T createEngineAdapter(IStorageAware aware, Class<T> engineInterface); }
StorageFactory { public static IStorage storage(IStorageAware aware) { if (configuredUseLocalStorage != null) { return configuredUseLocalStorage; } ImplementationSwitch<IStorage> current = storages.get(); if (storages.get() == null) { current = new ImplementationSwitch<>(KylinConfig.getInstanceFromEnv().getStorageEngines(), IStorage.class); storages.set(current); } return current.get(aware.getStorageType()); }  static IStorage storage(IStorageAware aware); static void clearCache(); static IStorageQuery createQuery(IRealization realization); static T createEngineAdapter(IStorageAware aware, Class<T> engineInterface);  }