Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[b/341297017] Integrate hist-cmd-types (AWR) from DMA #449

Merged
merged 8 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class StatsTaskListGenerator {

private final OracleConnectorScope scope = OracleConnectorScope.STATS;

private static final ImmutableList<String> AWR_NAMES =
ImmutableList.of("hist-cmd-types-awr", "source-conn-latest", "sql-stats-awr");

private static final ImmutableList<String> NATIVE_NAMES =
ImmutableList.of(
"data-types",
Expand All @@ -59,18 +62,14 @@ ImmutableList<Task<?>> createTasks(ConnectorArguments arguments) throws IOExcept
ImmutableList.Builder<Task<?>> builder = ImmutableList.<Task<?>>builder();
builder.add(new DumpMetadataTask(arguments, scope.formatName()));
builder.add(new FormatTask(scope.formatName()));
for (String name : awrNames()) {
OracleStatsQuery item = OracleStatsQuery.create(name, AWR);
builder.add(StatsJdbcTask.fromQuery(item));
}
for (String name : nativeNames()) {
OracleStatsQuery item = OracleStatsQuery.create(name, NATIVE);
builder.add(StatsJdbcTask.fromQuery(item));
}
ImmutableList<OracleStatsQuery> awr =
ImmutableList.of(
OracleStatsQuery.create("source-conn-latest", AWR),
OracleStatsQuery.create("sql-stats-awr", AWR));
for (OracleStatsQuery query : awr) {
builder.add(StatsJdbcTask.fromQuery(query));
}

for (String name : statspackNames()) {
OracleStatsQuery query = OracleStatsQuery.create(name, STATSPACK);
builder.add(StatsJdbcTask.fromQuery(query));
Expand All @@ -91,6 +90,10 @@ enum StatsSource {
}
}

ImmutableList<String> awrNames() {
return AWR_NAMES;
}

ImmutableList<String> nativeNames() {
return NATIVE_NAMES;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- Copyright 2022-2024 Google LLC
-- Copyright 2013-2021 CompilerWorks
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
SELECT
misolt marked this conversation as resolved.
Show resolved Hide resolved
A.con_id "ConId",
B.command_type "CommandType",
to_char(C.begin_interval_time, 'hh24') "Hour",
D.name "CommandName",
count(1) "Count",
sum(A.buffer_gets_total) "SumBufferGets",
sum(A.elapsed_time_total) "SumElapsedTime",
sum(A.rows_processed_total) "SumRowsProcessed",
sum(A.executions_total) "SumExecutions",
sum(A.cpu_time_total) "SumCpuTime",
sum(A.iowait_total) "SumIOWait",
sum(A.clwait_total) "SumCLWait",
sum(A.apwait_total) "SumAPWait",
sum(A.ccwait_total) "SumCCWait",
sum(A.plsexec_time_total) "SumPLSExecTime"
FROM cdb_hist_sqlstat A
INNER JOIN cdb_hist_sqltext B
ON A.con_id = B.con_id
AND A.sql_id = B.sql_id
AND A.dbid = B.dbid
INNER JOIN cdb_hist_snapshot C
ON A.snap_id = C.snap_id
AND A.dbid = C.dbid
AND A.instance_number = C.instance_number
LEFT JOIN audit_actions D
ON B.command_type = D.action
GROUP BY
A.con_id,
B.command_type,
to_char(C.begin_interval_time, 'hh24'),
D.name
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package com.google.edwmigration.dumper.application.dumper.connector.oracle;

import static com.google.edwmigration.dumper.application.dumper.connector.oracle.StatsTaskListGenerator.StatsSource.AWR;
import static com.google.edwmigration.dumper.application.dumper.connector.oracle.StatsTaskListGenerator.StatsSource.NATIVE;

import com.google.common.collect.ImmutableList;
Expand All @@ -30,11 +31,21 @@
public class StatsTaskListGeneratorTest {

@DataPoints("nativeNames")
public static final ImmutableList<String> nameList = new StatsTaskListGenerator().nativeNames();
public static final ImmutableList<String> nativeNames =
new StatsTaskListGenerator().nativeNames();

@DataPoints("awrNames")
public static final ImmutableList<String> awrNames = new StatsTaskListGenerator().awrNames();

@Theory
public void nativeNames_allNamedFilesExist(@FromDataPoints("nativeNames") String name)
throws IOException {
OracleStatsQuery.create(name, NATIVE);
}

@Theory
public void awrNames_allNamedFilesExist(@FromDataPoints("awrNames") String name)
throws IOException {
OracleStatsQuery.create(name, AWR);
}
}