This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 187469
Collapse All | Expand All

(-)a/dlight.management/src/org/netbeans/modules/dlight/management/api/DLightSession.java (-5 / +24 lines)
Lines 734-739 Link Here
734
                    context.addDLightTargetExecutionEnviromentProvider((DLightTarget.ExecutionEnvVariablesProvider) toolCollector);
734
                    context.addDLightTargetExecutionEnviromentProvider((DLightTarget.ExecutionEnvVariablesProvider) toolCollector);
735
                }
735
                }
736
736
737
                /*
738
                 * DataCollector usually acts as IndicatorDataProvider..
739
                 * It could be that infrastructure cannot provide all needed
740
                 * storages for the collector. This means that collector will
741
                 * not be able to *store* any data, still it *may* be able to
742
                 * act as an IndicatorDataProvider (with transient data).
743
                 *
744
                 * So do unconditional init with serviceInfoDataStorage.
745
                 * This will give a chance for collector to at least provide
746
                 * some information for Indicators...
747
                 *
748
                 * Note: It is collector's responsibility to handle the
749
                 * situation when it was not initialized with DataStorages!
750
                 *
751
                 * Note: Collector *will* be notified about session start even
752
                 * if it was not initialized with any DataStorage.
753
                 *
754
                 */
755
737
                if (currentStorages != null && !currentStorages.isEmpty()) {
756
                if (currentStorages != null && !currentStorages.isEmpty()) {
738
                    if (storages == null) {
757
                    if (storages == null) {
739
                        storages = new ArrayList<DataStorage>();
758
                        storages = new ArrayList<DataStorage>();
Lines 745-753 Link Here
745
                            storages.add(storage);
764
                            storages.add(storage);
746
                        }
765
                        }
747
                    }
766
                    }
748
                    toolCollector.init(serviceInfoDataStorage);
767
749
                    toolCollector.init(currentStorages, target);
768
                    toolCollector.init(currentStorages, target);
750
                    addDataFilterListener(toolCollector);
769
751
                    if (notAttachableDataCollector == null && !toolCollector.isAttachable()) {
770
                    if (notAttachableDataCollector == null && !toolCollector.isAttachable()) {
752
                        notAttachableDataCollector = toolCollector;
771
                        notAttachableDataCollector = toolCollector;
753
                    }
772
                    }
Lines 756-761 Link Here
756
                    log.log(Level.SEVERE, "Cannot find storage for collector {0}", toolCollector); // NOI18N
775
                    log.log(Level.SEVERE, "Cannot find storage for collector {0}", toolCollector); // NOI18N
757
                }
776
                }
758
777
778
                toolCollector.init(serviceInfoDataStorage);
779
                addDataFilterListener(toolCollector);
780
                
759
                target.addTargetListener(toolCollector);
781
                target.addTargetListener(toolCollector);
760
            }
782
            }
761
            for (DataCollector<?> c : collectors) {
783
            for (DataCollector<?> c : collectors) {
Lines 769-778 Link Here
769
                idp.init(serviceInfoDataStorage);
791
                idp.init(serviceInfoDataStorage);
770
                addDataFilterListener(idp);
792
                addDataFilterListener(idp);
771
            }
793
            }
772
773
        }
794
        }
774
795
775
776
        // at the end, initialize data filters (_temporarily_ here, as info
796
        // at the end, initialize data filters (_temporarily_ here, as info
777
        // about filters is stored in target's info...
797
        // about filters is stored in target's info...
778
798
Lines 792-798 Link Here
792
            ((SubstitutableTarget) target).substitute(notAttachableDataCollector.getCmd(), notAttachableDataCollector.getArgs());
812
            ((SubstitutableTarget) target).substitute(notAttachableDataCollector.getCmd(), notAttachableDataCollector.getArgs());
793
        }
813
        }
794
        return true;
814
        return true;
795
796
    }
815
    }
797
816
798
    /**
817
    /**
(-)a/dlight.management/src/org/netbeans/modules/dlight/management/api/impl/DataStorageManager.java (-9 / +45 lines)
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 137-152 Link Here
137
    }
138
    }
138
139
139
    /**
140
    /**
140
     *  Returns existing or  new instance of DataStorage
141
     * Returns existing or new instance of DataStorage
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)
143
     *
144
     * If collector requires several storages and infrastructure cannot provide
145
     * *all* of them, then an empty list is returned.
146
     * So this method guarantees to return either fully loaded map or nothing.
147
     *
142
     */
148
     */
143
    public synchronized  Map<DataStorageType, DataStorage> getDataStoragesFor(DLightSession session, DataCollector<?> collector) {
149
    public synchronized Map<DataStorageType, DataStorage> getDataStoragesFor(DLightSession session, DataCollector<?> collector) {
150
        if (session == null || collector == null) {
151
            return Collections.<DataStorageType, DataStorage>emptyMap();
152
        }
153
144
        Map<DataStorageType, DataStorage> result = new HashMap<DataStorageType, DataStorage>();
154
        Map<DataStorageType, DataStorage> result = new HashMap<DataStorageType, DataStorage>();
155
145
        for (DataStorageType type : collector.getRequiredDataStorageTypes()) {
156
        for (DataStorageType type : collector.getRequiredDataStorageTypes()) {
146
            result.put(type, getDataStorageFor(session, type, collector.getDataTablesMetadata()));
157
            final DataStorage dataStorage = getDataStorageFor(session, type, collector.getDataTablesMetadata());
147
        }
158
148
        return result;
159
            if (dataStorage == null) {
149
    }
160
                DLightLogger.getLogger(DataStorageManager.class).log(Level.INFO,
161
                        "DataStorageManager.getDataStoragesFor(DLightSession, DataCollector<?>):" // NOI18N
162
                        + " cannot find storage of type {0} [session={1}, collector={2}]." // NOI18N
163
                        + " NO storages will be returned", // NOI18N
164
                        new Object[]{type, session.getDisplayName(), collector.getName()});
165
                return Collections.<DataStorageType, DataStorage>emptyMap();
166
            }
167
168
            result.put(type, dataStorage);
169
         }
170
171
         return result;
172
     }
150
173
151
    public synchronized ServiceInfoDataStorage getServiceInfoDataStorageFor(String uniqueKey) {
174
    public synchronized ServiceInfoDataStorage getServiceInfoDataStorageFor(String uniqueKey) {
152
        if (uniqueKey == null) {
175
        if (uniqueKey == null) {
Lines 484-492 Link Here
484
                DataStorage newStorage = storage.createStorage();
507
                DataStorage newStorage = storage.createStorage();
485
                if (newStorage instanceof ProxyDataStorage) {
508
                if (newStorage instanceof ProxyDataStorage) {
486
                    ProxyDataStorage proxyStorage = (ProxyDataStorage) newStorage;
509
                    ProxyDataStorage proxyStorage = (ProxyDataStorage) newStorage;
487
                    DataStorage backendStorage = getDataStorageFor(session, proxyStorage.getBackendDataStorageType(), proxyStorage.getBackendTablesMetadata());
510
                    DataStorageType requiredStorageType = proxyStorage.getBackendDataStorageType();
511
                    List<DataTableMetadata> requiredTables = proxyStorage.getBackendTablesMetadata();
512
                    DataStorage backendStorage = getDataStorageFor(session, requiredStorageType, requiredTables);
513
                    if (backendStorage == null) {
514
                        // Means that required (for this proxy) storage cannot be found ...
515
                        continue;
516
                    }
488
                    proxyStorage.attachTo(backendStorage);
517
                    proxyStorage.attachTo(backendStorage);
489
                }
518
                }
519
490
                if (newStorage != null) {
520
                if (newStorage != null) {
491
                    newStorage.createTables(tableMetadatas);
521
                    newStorage.createTables(tableMetadatas);
492
                    if (activeSessionStorages == null) {
522
                    if (activeSessionStorages == null) {
Lines 507-515 Link Here
507
                    if (newStorage != null) {
537
                    if (newStorage != null) {
508
                        if (newStorage instanceof ProxyDataStorage) {
538
                        if (newStorage instanceof ProxyDataStorage) {
509
                            ProxyDataStorage proxyStorage = (ProxyDataStorage) newStorage;
539
                            ProxyDataStorage proxyStorage = (ProxyDataStorage) newStorage;
510
                            DataStorage backendStorage = getDataStorageFor(session, proxyStorage.getBackendDataStorageType(), proxyStorage.getBackendTablesMetadata());
540
                            DataStorageType requiredStorageType = proxyStorage.getBackendDataStorageType();
541
                            List<DataTableMetadata> requiredTables = proxyStorage.getBackendTablesMetadata();
542
                            DataStorage backendStorage = getDataStorageFor(session, requiredStorageType, requiredTables);
543
                            if (backendStorage == null) {
544
                                continue;
545
                            }
511
                            proxyStorage.attachTo(backendStorage);
546
                            proxyStorage.attachTo(backendStorage);
512
                        }
547
                        }
548
513
                        newStorage.createTables(tableMetadatas);
549
                        newStorage.createTables(tableMetadatas);
514
550
515
                        return newStorage;
551
                        return newStorage;

Return to bug 187469