|
70 | 70 | import io.cdap.cdap.metadata.PreferencesFetcher;
|
71 | 71 | import io.cdap.cdap.metadata.RemotePreferencesFetcherInternal;
|
72 | 72 | import io.cdap.cdap.metrics.guice.MetricsClientRuntimeModule;
|
| 73 | +import io.cdap.cdap.proto.ProgramType; |
| 74 | +import io.cdap.cdap.proto.id.NamespaceId; |
73 | 75 | import io.cdap.cdap.proto.id.ProgramId;
|
74 | 76 | import io.cdap.cdap.proto.id.ProgramRunId;
|
75 | 77 | import io.cdap.cdap.runtime.spi.RuntimeMonitorType;
|
@@ -159,7 +161,7 @@ private List<Module> getCoreModules() {
|
159 | 161 |
|
160 | 162 | List<Module> modules = new ArrayList<>();
|
161 | 163 |
|
162 |
| - modules.add(new NoOpAuditLogModule()); |
| 164 | + modules.add(getAuditLogModules()); |
163 | 165 | modules.add(new ConfigModule(cConf, hConf));
|
164 | 166 | modules.add(new IOModule());
|
165 | 167 | modules.add(new DFSLocationModule());
|
@@ -303,6 +305,18 @@ private static String generateClientId(ProgramRunId programRunId, String instanc
|
303 | 305 | return String.format("%s.%s.%s", programRunId.getParent(), programRunId.getRun(), instanceId);
|
304 | 306 | }
|
305 | 307 |
|
| 308 | + /** |
| 309 | + * Return distributed module only if the program is of SERVICE in SYSTEM namespace. |
| 310 | + */ |
| 311 | + private Module getAuditLogModules() { |
| 312 | + if (programRunId.getNamespaceId().equals(NamespaceId.SYSTEM) |
| 313 | + && programRunId.getType().equals(ProgramType.SERVICE)) { |
| 314 | + return new AuditLogWriterModule(cConf).getDistributedModules(); |
| 315 | + } |
| 316 | + |
| 317 | + return new NoOpAuditLogModule(); |
| 318 | + } |
| 319 | + |
306 | 320 | /**
|
307 | 321 | * A Guice module to provide {@link ProgramStateWriter} binding. In normal same cluster / remote
|
308 | 322 | * cluster execution, it just publishes program states to TMS based on the discovery service. For
|
|
0 commit comments