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 202324
Collapse All | Expand All

(-)a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/dataprovider/impl/FunctionsListDataProviderImpl.java (-1 / +22 lines)
Lines 49-58 Link Here
49
import org.netbeans.modules.dlight.api.storage.DataTableMetadata.Column;
49
import org.netbeans.modules.dlight.api.storage.DataTableMetadata.Column;
50
import org.netbeans.modules.dlight.core.stack.api.FunctionCall;
50
import org.netbeans.modules.dlight.core.stack.api.FunctionCall;
51
import org.netbeans.modules.dlight.core.stack.api.FunctionCallWithMetric;
51
import org.netbeans.modules.dlight.core.stack.api.FunctionCallWithMetric;
52
import org.netbeans.modules.dlight.core.stack.api.FunctionContext;
52
import org.netbeans.modules.dlight.core.stack.api.FunctionMetric;
53
import org.netbeans.modules.dlight.core.stack.api.FunctionMetric;
53
import org.netbeans.modules.dlight.core.stack.api.support.FunctionDatatableDescription;
54
import org.netbeans.modules.dlight.core.stack.api.support.FunctionDatatableDescription;
54
import org.netbeans.modules.dlight.core.stack.dataprovider.FunctionCallTreeTableNode;
55
import org.netbeans.modules.dlight.core.stack.dataprovider.FunctionCallTreeTableNode;
55
import org.netbeans.modules.dlight.core.stack.dataprovider.FunctionsListDataProvider;
56
import org.netbeans.modules.dlight.core.stack.dataprovider.FunctionsListDataProvider;
57
import org.netbeans.modules.dlight.core.stack.dataprovider.SourceFileInfoDataProvider;
58
import org.netbeans.modules.dlight.core.stack.storage.FunctionContextStorage;
56
import org.netbeans.modules.dlight.core.stack.storage.StackDataStorage;
59
import org.netbeans.modules.dlight.core.stack.storage.StackDataStorage;
57
import org.netbeans.modules.dlight.spi.SourceFileInfoProvider;
60
import org.netbeans.modules.dlight.spi.SourceFileInfoProvider;
58
import org.netbeans.modules.dlight.spi.SourceFileInfoProvider.SourceFileInfo;
61
import org.netbeans.modules.dlight.spi.SourceFileInfoProvider.SourceFileInfo;
Lines 90-96 Link Here
90
        synchronized(lock) {
93
        synchronized(lock) {
91
            filtersCopy = new ArrayList<DataFilter>(filters);
94
            filtersCopy = new ArrayList<DataFilter>(filters);
92
        }
95
        }
93
        if (functionDescription.getOffsetColumnName() == null) {
96
        if (functionDescription.getOffsetColumnName() == null && functionDescription.getContextIDColumnName() == null) {
94
            List<FunctionCallWithMetric> result = new ArrayList<FunctionCallWithMetric>();
97
            List<FunctionCallWithMetric> result = new ArrayList<FunctionCallWithMetric>();
95
            List<FunctionCallTreeTableNode> nodes = FunctionCallTreeTableNode.getFunctionCallTreeTableNodes(storage.getHotSpotFunctions(FunctionMetric.CpuTimeExclusiveMetric, filtersCopy, Integer.MAX_VALUE));
98
            List<FunctionCallTreeTableNode> nodes = FunctionCallTreeTableNode.getFunctionCallTreeTableNodes(storage.getHotSpotFunctions(FunctionMetric.CpuTimeExclusiveMetric, filtersCopy, Integer.MAX_VALUE));
96
            for (FunctionCallTreeTableNode node : nodes) {
99
            for (FunctionCallTreeTableNode node : nodes) {
Lines 113-118 Link Here
113
    @Override
116
    @Override
114
    public SourceFileInfo getSourceFileInfo(FunctionCall functionCall) {
117
    public SourceFileInfo getSourceFileInfo(FunctionCall functionCall) {
115
        //we should get here SourceFileInfoProvider
118
        //we should get here SourceFileInfoProvider
119
        Collection<? extends FunctionContextStorage> fcStorages = Lookup.getDefault().lookupAll(FunctionContextStorage.class);
120
121
        if (fcStorages != null) {
122
            for (FunctionContextStorage fcStorage : fcStorages) {
123
                FunctionContext context = fcStorage.getFunctionContext(functionCall.getFunction().getContextID());
124
125
                if (context == null) {
126
                    continue;
127
                }
128
129
                SourceFileInfoDataProvider infoProvider = context.getLookup().lookup(SourceFileInfoDataProvider.class);
130
131
                if (infoProvider != null) {
132
                    return infoProvider.getSourceFileInfo(functionCall);
133
                }
134
            }
135
        }
136
116
        Collection<? extends SourceFileInfoProvider> sourceInfoProviders =
137
        Collection<? extends SourceFileInfoProvider> sourceInfoProviders =
117
                Lookup.getDefault().lookupAll(SourceFileInfoProvider.class);
138
                Lookup.getDefault().lookupAll(SourceFileInfoProvider.class);
118
139
(-)a/dlight.core.stack/src/org/netbeans/modules/dlight/core/stack/storage/impl/SQLStackDataStorage.java (-5 / +66 lines)
Lines 103-108 Link Here
103
import org.netbeans.modules.dlight.util.DLightLogger;
103
import org.netbeans.modules.dlight.util.DLightLogger;
104
import org.netbeans.modules.dlight.util.Range;
104
import org.netbeans.modules.dlight.util.Range;
105
import org.netbeans.modules.dlight.util.Util;
105
import org.netbeans.modules.dlight.util.Util;
106
import org.openide.util.Exceptions;
106
import org.openide.util.Lookup;
107
import org.openide.util.Lookup;
107
import org.openide.util.NotImplementedException;
108
import org.openide.util.NotImplementedException;
108
109
Lines 114-120 Link Here
114
115
115
    private static final Logger LOG = DLightLogger.getLogger(SQLStackDataStorage.class);
116
    private static final Logger LOG = DLightLogger.getLogger(SQLStackDataStorage.class);
116
    private static final CallStackEntryParser defaultParser = new DefaultStackParserImpl();
117
    private static final CallStackEntryParser defaultParser = new DefaultStackParserImpl();
117
    private final List<DataTableMetadata> tableMetadatas;
118
    private static final HashMap<Class<?>, String> classToType = new HashMap<Class<?>, String>();
119
    
120
    private final HashMap<String, DataTableMetadata> tableMetadatas;
118
    private final AtomicBoolean closed = new AtomicBoolean(false);
121
    private final AtomicBoolean closed = new AtomicBoolean(false);
119
    private DBProxy dbProxy;
122
    private DBProxy dbProxy;
120
    private SQLRequestsProcessor requestsProcessor;
123
    private SQLRequestsProcessor requestsProcessor;
Lines 124-131 Link Here
124
    private CppSymbolDemangler demangler;
127
    private CppSymbolDemangler demangler;
125
    private ServiceInfoDataStorage serviceInfoDataStorage;
128
    private ServiceInfoDataStorage serviceInfoDataStorage;
126
129
130
    static {
131
        classToType.put(Byte.class, "tinyint");     // NOI18N
132
        classToType.put(Short.class, "smallint");   // NOI18N
133
        classToType.put(Integer.class, "int");      // NOI18N
134
        classToType.put(Long.class, "bigint");      // NOI18N
135
        classToType.put(Double.class, "double");    // NOI18N
136
        classToType.put(Float.class, "real");       // NOI18N
137
        classToType.put(String.class, "varchar");   // NOI18N
138
        classToType.put(Time.class, "bigint");      // NOI18N
139
    }
140
    
127
    public SQLStackDataStorage() {
141
    public SQLStackDataStorage() {
128
        tableMetadatas = new ArrayList<DataTableMetadata>();
142
        tableMetadatas = new HashMap<String, DataTableMetadata>();
129
    }
143
    }
130
144
131
    @Override
145
    @Override
Lines 164-169 Link Here
164
        dbProxy = new DBProxy(requestsProcessor, requestsProvider);
178
        dbProxy = new DBProxy(requestsProcessor, requestsProvider);
165
179
166
        initTables();
180
        initTables();
181
        loadSchema();
167
    }
182
    }
168
183
169
    private <T extends DataFilter> Collection<T> getDataFilters(List<DataFilter> filters, Class<T> clazz) {
184
    private <T extends DataFilter> Collection<T> getDataFilters(List<DataFilter> filters, Class<T> clazz) {
Lines 178-184 Link Here
178
193
179
    @Override
194
    @Override
180
    public boolean hasData(DataTableMetadata data) {
195
    public boolean hasData(DataTableMetadata data) {
181
        return data.isProvidedBy(tableMetadatas);
196
        return data.isProvidedBy(new ArrayList<DataTableMetadata>(tableMetadatas.values()));
182
    }
197
    }
183
198
184
    @Override
199
    @Override
Lines 198-204 Link Here
198
213
199
    @Override
214
    @Override
200
    public void createTables(List<DataTableMetadata> tableMetadatas) {
215
    public void createTables(List<DataTableMetadata> tableMetadatas) {
201
        this.tableMetadatas.addAll(tableMetadatas);
216
        for (DataTableMetadata dataTableMetadata : tableMetadatas) {
217
            this.tableMetadatas.put(dataTableMetadata.getName(), dataTableMetadata);
218
        }
202
    }
219
    }
203
220
204
    // For tests ... 
221
    // For tests ... 
Lines 269-274 Link Here
269
        }
286
        }
270
    }
287
    }
271
288
289
    private void loadSchema() {
290
        try {
291
            ResultSet rs = sqlStorage.select("INFORMATION_SCHEMA.TABLES", null, // NOI18N
292
                    "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE LIKE 'TABLE'"); // NOI18N
293
            
294
            if (rs == null) {
295
                return;
296
            }
297
            
298
            while (rs.next()) {
299
                String tableName = rs.getString(1);
300
                loadTable(tableName);
301
            }
302
        } catch (SQLException ex) {
303
            Exceptions.printStackTrace(ex);
304
        }
305
    }
306
307
    protected Class<?> typeToClass(String type) {
308
        Set<Class<?>> clazzes = classToType.keySet();
309
        for (Class<?> clazz : clazzes) {
310
            if (classToType.get(clazz).equalsIgnoreCase(type)) {
311
                return clazz;
312
            }
313
        }
314
        return String.class;
315
    }
316
    
317
    private void loadTable(String tableName) {
318
        try {
319
            ResultSet rs = sqlStorage.select("INFORMATION_SCHEMA.COLUMNS", null, "SELECT COLUMN_NAME, "// NOI18N
320
                    + "TYPE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME LIKE '" + tableName + "'");// NOI18N
321
            List<Column> columns = new ArrayList<Column>();
322
            while (rs.next()) {
323
                Column c = new Column(rs.getString("COLUMN_NAME"), typeToClass(rs.getString("TYPE_NAME")));// NOI18N
324
                columns.add(c);
325
            }
326
            DataTableMetadata result = new DataTableMetadata(tableName, columns, null);
327
//            sqlStorage.loadTable(result);
328
            tableMetadatas.put(tableName, result);
329
        } catch (SQLException ex) {
330
            Exceptions.printStackTrace(ex);
331
        }
332
    }    
333
272
    @Override
334
    @Override
273
    public long putStack(long contextID, List<CharSequence> stack) {
335
    public long putStack(long contextID, List<CharSequence> stack) {
274
        // Even if this stack has no any associated metrics, we need to store the 
336
        // Even if this stack has no any associated metrics, we need to store the 
Lines 440-446 Link Here
440
                    Map<FunctionMetric, Object> metricValues = new HashMap<FunctionMetric, Object>();
502
                    Map<FunctionMetric, Object> metricValues = new HashMap<FunctionMetric, Object>();
441
                    for (FunctionMetric m : metrics) {
503
                    for (FunctionMetric m : metrics) {
442
                        try {
504
                        try {
443
                            rs.findColumn(m.getMetricID());
444
                            Object value = rs.getObject(m.getMetricID());
505
                            Object value = rs.getObject(m.getMetricID());
445
                            if (m.getMetricValueClass() == Time.class && value != null) {
506
                            if (m.getMetricValueClass() == Time.class && value != null) {
446
                                value = new Time(Long.valueOf(value.toString()));
507
                                value = new Time(Long.valueOf(value.toString()));
(-)a/dlight.visualizers/src/org/netbeans/modules/dlight/visualizers/GotoSourceActionProvider.java (-3 / +3 lines)
Lines 54-60 Link Here
54
import java.util.concurrent.locks.ReentrantLock;
54
import java.util.concurrent.locks.ReentrantLock;
55
import javax.swing.AbstractAction;
55
import javax.swing.AbstractAction;
56
import org.netbeans.modules.dlight.core.stack.api.FunctionCallWithMetric;
56
import org.netbeans.modules.dlight.core.stack.api.FunctionCallWithMetric;
57
import org.netbeans.modules.dlight.core.stack.dataprovider.FunctionsListDataProvider;
57
import org.netbeans.modules.dlight.core.stack.dataprovider.SourceFileInfoDataProvider;
58
import org.netbeans.modules.dlight.spi.SourceFileInfoProvider.SourceFileInfo;
58
import org.netbeans.modules.dlight.spi.SourceFileInfoProvider.SourceFileInfo;
59
import org.netbeans.modules.dlight.spi.SourceSupportProvider;
59
import org.netbeans.modules.dlight.spi.SourceSupportProvider;
60
import org.netbeans.modules.dlight.util.DLightExecutorService;
60
import org.netbeans.modules.dlight.util.DLightExecutorService;
Lines 70-76 Link Here
70
public final class GotoSourceActionProvider {
70
public final class GotoSourceActionProvider {
71
71
72
    private final RequestProcessor RP = new RequestProcessor(GotoSourceActionProvider.class.getName(), 1);
72
    private final RequestProcessor RP = new RequestProcessor(GotoSourceActionProvider.class.getName(), 1);
73
    private final FunctionsListDataProvider dataprovider;
73
    private final SourceFileInfoDataProvider dataprovider;
74
    private final SourceSupportProvider sourceSupportProvider;
74
    private final SourceSupportProvider sourceSupportProvider;
75
    private final LinkedBlockingQueue<Request> queue = new LinkedBlockingQueue<Request>();
75
    private final LinkedBlockingQueue<Request> queue = new LinkedBlockingQueue<Request>();
76
    private final ReentrantLock lock = new ReentrantLock();
76
    private final ReentrantLock lock = new ReentrantLock();
Lines 79-85 Link Here
79
            new HashMap<Integer, GotoSourceAction>();
79
            new HashMap<Integer, GotoSourceAction>();
80
    private Future<?> task = null;
80
    private Future<?> task = null;
81
81
82
    public GotoSourceActionProvider(SourceSupportProvider sourceSupportProvider, FunctionsListDataProvider dataprovider) {
82
    public GotoSourceActionProvider(SourceSupportProvider sourceSupportProvider, SourceFileInfoDataProvider dataprovider) {
83
        this.dataprovider = dataprovider;
83
        this.dataprovider = dataprovider;
84
        this.sourceSupportProvider = sourceSupportProvider;
84
        this.sourceSupportProvider = sourceSupportProvider;
85
    }
85
    }
(-)a/dlight.visualizers/src/org/netbeans/modules/dlight/visualizers/ui/FunctionCallNode.java (-2 / +7 lines)
Lines 196-207 Link Here
196
        String infoSuffix = null;
196
        String infoSuffix = null;
197
197
198
        if (action != null && action.isEnabled()) {
198
        if (action != null && action.isEnabled()) {
199
            result.append("<font color='#000000'>").append(dispName).append("</font>"); // NOI18N
200
201
            SourceFileInfo sourceInfo = action.getSourceInfo();
199
            SourceFileInfo sourceInfo = action.getSourceInfo();
202
            if (sourceInfo != null && sourceInfo.isSourceKnown()) {
200
            if (sourceInfo != null && sourceInfo.isSourceKnown()) {
203
                String fname = new File(sourceInfo.getFileName()).getName();
201
                String fname = new File(sourceInfo.getFileName()).getName();
204
                int line = sourceInfo.getLine();
202
                int line = sourceInfo.getLine();
203
204
                if (line > 0) {
205
                    result.append("<font color='#000000'>").append(dispName).append("</font>"); // NOI18N
206
                } else {
207
                    result.append("<font color='#808080'>").append(dispName).append("</font>"); // NOI18N
208
                }
209
205
                String infoPrefix = line > 0
210
                String infoPrefix = line > 0
206
                        ? NbBundle.getMessage(FunctionCallNode.class, "FunctionCallNode.prefix.withLine") // NOI18N
211
                        ? NbBundle.getMessage(FunctionCallNode.class, "FunctionCallNode.prefix.withLine") // NOI18N
207
                        : NbBundle.getMessage(FunctionCallNode.class, "FunctionCallNode.prefix.withoutLine"); // NOI18N
212
                        : NbBundle.getMessage(FunctionCallNode.class, "FunctionCallNode.prefix.withoutLine"); // NOI18N
(-)a/dlight/src/org/netbeans/modules/dlight/spi/support/SQLDataStorage.java (+6 lines)
Lines 215-220 Link Here
215
            if (columns.contains(filterColumn)) {
215
            if (columns.contains(filterColumn)) {
216
                Range<?> range = filter.getNumericDataFilter().getInterval();
216
                Range<?> range = filter.getNumericDataFilter().getInterval();
217
                if (range.getStart() != null || range.getEnd() != null) {
217
                if (range.getStart() != null || range.getEnd() != null) {
218
                    // TODO: this is a workaround ...
219
                    if (filterColumn.getColumnName().equals("bucket")) { // NOI18N
220
                        Number start = range.getStart();
221
                        Number end = range.getEnd();
222
                        range = new Range<Long>(start.longValue() / 1000000000, end.longValue() / 1000000000);
223
                    }
218
                    whereClause = range.toString(" WHERE ", "%d <= " + filterColumn.getColumnName(), " AND ", filterColumn.getColumnName() + " <= %d", null); // NOI18N
224
                    whereClause = range.toString(" WHERE ", "%d <= " + filterColumn.getColumnName(), " AND ", filterColumn.getColumnName() + " <= %d", null); // NOI18N
219
                    break;
225
                    break;
220
                }
226
                }

Return to bug 202324