public List processTables()

in services/library/src/main/java/com/google/cloud/pso/bq_pii_classifier/functions/dispatcher/Dispatcher.java [169:219]


    public List<JsonMessage> processTables(List<String> tableIncludeList,
                                           List<String> tableExcludeList,
                                           List<String> inspectionTemplatesIds,
                                           String dlpJobRegion
    ) {
        List<JsonMessage> pubSubMessagesToPublish = new ArrayList<>();

        // entity is a table spec string p.d.t in case of Standard Mode Inspection Dispatcher and sent to the Inspector Service
        // entity is a table spec string p.d.t in case of Auto DLP mode Tagging Dispatcher and sent to the Tagger Service
        // entity is a dlpJobName in case of Standard Mode Tagging Dispatcher and sent to the Tagger Service
        for (String entity : tableIncludeList) {
            try {
                if (!tableExcludeList.contains(entity)) {

                    String trackingId = TrackingHelper.generateTrackingId(runId, entity);

                    if (config.getSolutionMode().equals(SolutionMode.STANDARD_DLP) && config.getDispatcherType().equals(DispatcherType.INSPECTION)) {

                        for (int i = 0; i < inspectionTemplatesIds.size(); i++) {
                            // submit n inspection requests depending on the number of inspection templates in one region
                            InspectorRequest operation = new InspectorRequest(
                                    runId,
                                    String.format("%s_%s", trackingId, (i + 1)), // use tabletrackingid_inspectiontemplatenumber to diff between requests and paths
                                    TableSpec.fromSqlString(entity),
                                    inspectionTemplatesIds.get(i),
                                    dlpJobRegion); // run the dlp job in the same region as the source table to avoid network cost
                            pubSubMessagesToPublish.add(operation);
                        }

                    } else {
                        if (config.getSolutionMode().equals(SolutionMode.AUTO_DLP)) {
                            TaggerTableSpecRequest operation = new TaggerTableSpecRequest(runId, trackingId, TableSpec.fromSqlString(entity));
                            pubSubMessagesToPublish.add(operation);
                        } else {
                            if (config.getSolutionMode().equals(SolutionMode.STANDARD_DLP) && config.getDispatcherType().equals(DispatcherType.TAGGING)) {
                                TaggerDlpJobRequest operation = new TaggerDlpJobRequest(runId, trackingId, entity);
                                pubSubMessagesToPublish.add(operation);
                            } else {
                                throw new NonRetryableApplicationException(String.format("Solution Mode %s and Dispatcher Type %s are not supported in the Dispatcher logic",
                                        config.getSolutionMode(), config.getDispatcherType()));
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                // log and continue
                logger.logFailedDispatcherEntityId(runId, entity, ex);
            }
        }
        return pubSubMessagesToPublish;
    }