Lines 43-48
Link Here
|
43 |
|
43 |
|
44 |
import java.util.ArrayList; |
44 |
import java.util.ArrayList; |
45 |
import java.util.Collection; |
45 |
import java.util.Collection; |
|
|
46 |
import java.util.Collections; |
46 |
import java.util.HashMap; |
47 |
import java.util.HashMap; |
47 |
import java.util.List; |
48 |
import java.util.List; |
48 |
import java.util.Map; |
49 |
import java.util.Map; |
Lines 141-150
Link Here
|
141 |
* for requested schema (if it can be found within all available DataStorages) |
142 |
* for requested schema (if it can be found within all available DataStorages) |
142 |
*/ |
143 |
*/ |
143 |
public synchronized Map<DataStorageType, DataStorage> getDataStoragesFor(DLightSession session, DataCollector<?> collector) { |
144 |
public synchronized Map<DataStorageType, DataStorage> getDataStoragesFor(DLightSession session, DataCollector<?> collector) { |
|
|
145 |
if (session == null || collector == null) { |
146 |
return Collections.<DataStorageType, DataStorage>emptyMap(); |
147 |
} |
148 |
|
144 |
Map<DataStorageType, DataStorage> result = new HashMap<DataStorageType, DataStorage>(); |
149 |
Map<DataStorageType, DataStorage> result = new HashMap<DataStorageType, DataStorage>(); |
|
|
150 |
|
145 |
for (DataStorageType type : collector.getRequiredDataStorageTypes()) { |
151 |
for (DataStorageType type : collector.getRequiredDataStorageTypes()) { |
146 |
result.put(type, getDataStorageFor(session, type, collector.getDataTablesMetadata())); |
152 |
final DataStorage dataStorage = getDataStorageFor(session, type, collector.getDataTablesMetadata()); |
|
|
153 |
|
154 |
if (dataStorage != null) { |
155 |
result.put(type, dataStorage); |
156 |
} else { |
157 |
DLightLogger.getLogger(DataStorageManager.class).log(Level.INFO, |
158 |
"DataStorageManager.getDataStoragesFor(DLightSession, DataCollector<?>):" // NOI18N |
159 |
+ " NULL storage returned for type={0} [session={1}, collector={2}]", // NOI18N |
160 |
new Object[] {type, session.getDisplayName(), collector.getName()}); |
161 |
} |
147 |
} |
162 |
} |
|
|
163 |
|
148 |
return result; |
164 |
return result; |
149 |
} |
165 |
} |
150 |
|
166 |
|
Lines 484-492
Link Here
|
484 |
DataStorage newStorage = storage.createStorage(); |
500 |
DataStorage newStorage = storage.createStorage(); |
485 |
if (newStorage instanceof ProxyDataStorage) { |
501 |
if (newStorage instanceof ProxyDataStorage) { |
486 |
ProxyDataStorage proxyStorage = (ProxyDataStorage) newStorage; |
502 |
ProxyDataStorage proxyStorage = (ProxyDataStorage) newStorage; |
487 |
DataStorage backendStorage = getDataStorageFor(session, proxyStorage.getBackendDataStorageType(), proxyStorage.getBackendTablesMetadata()); |
503 |
DataStorageType requiredStorageType = proxyStorage.getBackendDataStorageType(); |
|
|
504 |
List<DataTableMetadata> requiredTables = proxyStorage.getBackendTablesMetadata(); |
505 |
DataStorage backendStorage = getDataStorageFor(session, requiredStorageType, requiredTables); |
506 |
if (backendStorage == null) { |
507 |
// Means that required (for this proxy) storage cannot be found ... |
508 |
continue; |
509 |
} |
488 |
proxyStorage.attachTo(backendStorage); |
510 |
proxyStorage.attachTo(backendStorage); |
489 |
} |
511 |
} |
|
|
512 |
|
490 |
if (newStorage != null) { |
513 |
if (newStorage != null) { |
491 |
newStorage.createTables(tableMetadatas); |
514 |
newStorage.createTables(tableMetadatas); |
492 |
if (activeSessionStorages == null) { |
515 |
if (activeSessionStorages == null) { |
Lines 507-515
Link Here
|
507 |
if (newStorage != null) { |
530 |
if (newStorage != null) { |
508 |
if (newStorage instanceof ProxyDataStorage) { |
531 |
if (newStorage instanceof ProxyDataStorage) { |
509 |
ProxyDataStorage proxyStorage = (ProxyDataStorage) newStorage; |
532 |
ProxyDataStorage proxyStorage = (ProxyDataStorage) newStorage; |
510 |
DataStorage backendStorage = getDataStorageFor(session, proxyStorage.getBackendDataStorageType(), proxyStorage.getBackendTablesMetadata()); |
533 |
DataStorageType requiredStorageType = proxyStorage.getBackendDataStorageType(); |
|
|
534 |
List<DataTableMetadata> requiredTables = proxyStorage.getBackendTablesMetadata(); |
535 |
DataStorage backendStorage = getDataStorageFor(session, requiredStorageType, requiredTables); |
536 |
if (backendStorage == null) { |
537 |
continue; |
538 |
} |
511 |
proxyStorage.attachTo(backendStorage); |
539 |
proxyStorage.attachTo(backendStorage); |
512 |
} |
540 |
} |
|
|
541 |
|
513 |
newStorage.createTables(tableMetadatas); |
542 |
newStorage.createTables(tableMetadatas); |
514 |
|
543 |
|
515 |
return newStorage; |
544 |
return newStorage; |