Commit bf5158f3 authored by Komal Makkar's avatar Komal Makkar
Browse files

intermediate changes

parent a015a3bf
Pipeline #31643 failed with stage
in 1 minute and 55 seconds
......@@ -19,7 +19,11 @@ import com.microsoft.azure.eventgrid.models.EventGridEvent;
import lombok.SneakyThrows;
import org.opengroup.osdu.azure.cosmosdb.CosmosStoreBulkOperations;
import org.opengroup.osdu.azure.partition.PartitionServiceEventGridClient;
import org.opengroup.osdu.azure.partition.adapters.EventGridPartitionConfigAdapter;
import org.opengroup.osdu.azure.partition.adapters.IAzureResourcePartitionConfigAdapter;
import org.opengroup.osdu.azure.partition.models.EventGridPartitionConfig;
import org.opengroup.osdu.azure.partition.models.EventGridTopicPartitionInfoAzure;
import org.opengroup.osdu.azure.partition.providers.PartitionInfoProvider;
import org.opengroup.osdu.core.common.logging.ILogger;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.slf4j.Logger;
......@@ -60,13 +64,19 @@ import java.util.List;
public class EventGridTopicStore {
private static final Logger LOGGER = LoggerFactory.getLogger(CosmosStoreBulkOperations.class.getName());
@Autowired
private IAzureResourcePartitionConfigAdapter adapter;
private PartitionInfoProvider partitionInfoProvider;
private IEventGridTopicClientFactory eventGridTopicClientFactory;
@Autowired
private ILogger logger;
@Autowired
private PartitionServiceEventGridClient eventGridPartitionClient;
@Autowired
public EventGridTopicStore(PartitionInfoProvider partitionInfoProvider, IEventGridTopicClientFactory eventGridTopicClientFactory, PartitionServiceEventGridClient eventGridPartitionClient) {
this.adapter = new EventGridPartitionConfigAdapter();
this.partitionInfoProvider = partitionInfoProvider;
this.eventGridTopicClientFactory = eventGridTopicClientFactory;
this.eventGridPartitionClient = eventGridPartitionClient;
}
/**
* @param dataPartitionId Data partition id
* @param topicName Topic name
......@@ -76,6 +86,10 @@ public class EventGridTopicStore {
public void publishToEventGridTopic(final String dataPartitionId, final String topicName, final List<EventGridEvent> eventsList) {
EventGridTopicPartitionInfoAzure eventGridTopicPartitionInfoAzure = this.eventGridPartitionClient.getEventGridTopicInPartition(dataPartitionId, topicName);
/*EventGridPartitionConfig eventGridPartitionConfig = (EventGridPartitionConfig) adapter.getConfig(
partitionInfoProvider.getPartitionInfo(dataPartitionId),
dataPartitionId);*/
String endpoint;
try {
endpoint = String.format("https://%s/", new URI(eventGridTopicPartitionInfoAzure.getTopicName()).getHost());
......@@ -84,7 +98,5 @@ public class EventGridTopicStore {
}
EventGridClient eventGridClient = eventGridTopicClientFactory.getClient(dataPartitionId, topicName);
eventGridClient.publishEvents(endpoint, eventsList);
}
}
......@@ -17,17 +17,20 @@ package org.opengroup.osdu.azure.partition.adapters;
import com.azure.security.keyvault.secrets.SecretClient;
import org.opengroup.osdu.azure.partition.models.EventGridPartitionConfig;
import org.opengroup.osdu.azure.partition.models.EventGridTopicPartitionInfoAzure;
import org.opengroup.osdu.core.common.partition.PartitionInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
public class EventGridPartitionConfigAdapter extends AzureResourcePartitionConfigAdapter {
@Component
public class EventGridPartitionConfigAdapter implements IAzureResourcePartitionConfigAdapter {
@Autowired
private SecretClient secretClient;
@Override
public EventGridPartitionConfig getConfig(String partitionId) {
public EventGridPartitionConfig getConfig(PartitionInfo partitionInfo, String partitionId) {
return new EventGridPartitionConfig(new HashMap<String, EventGridTopicPartitionInfoAzure>());
}
}
......@@ -14,17 +14,10 @@
package org.opengroup.osdu.azure.partition.adapters;
import org.opengroup.osdu.azure.partition.models.IAzureResourcePartitionConfig;
import org.opengroup.osdu.azure.util.AzureServicePrincipleTokenService;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.partition.IPartitionFactory;
import org.opengroup.osdu.core.common.partition.IPartitionProvider;
import org.opengroup.osdu.core.common.partition.PartitionException;
import org.opengroup.osdu.core.common.partition.PartitionInfo;
import org.springframework.beans.factory.annotation.Autowired;
public interface IAzureResourcePartitionConfigAdapter {
public interface IAzureResourcePartitionConfigAdapter<T> {
public abstract IAzureResourcePartitionConfig getConfig(String partitionId);
public <T> T getConfig(PartitionInfo partitionInfo, String partitionId);
}
......@@ -21,6 +21,6 @@ import java.util.Map;
@AllArgsConstructor
@Getter
public class EventGridPartitionConfig extends IAzureResourcePartitionConfig {
public class EventGridPartitionConfig {
Map<String, EventGridTopicPartitionInfoAzure> topicsRegistered;
}
// Copyright © Microsoft Corporation
//
// 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.
package org.opengroup.osdu.azure.partition.models;
public class IAzureResourcePartitionConfig {
}
......@@ -16,7 +16,7 @@ import org.opengroup.osdu.core.common.partition.Property;
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PartitionInfoAzure extends IAzureResourcePartitionConfig {
public class PartitionInfoAzure {
@SerializedName("id")
private Property idConfig;
......
// Copyright © Microsoft Corporation
//
// 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.
package org.opengroup.osdu.azure.partition.providers;
import org.opengroup.osdu.azure.partition.adapters.EventGridPartitionConfigAdapter;
import org.opengroup.osdu.azure.partition.models.EventGridPartitionConfig;
import org.springframework.beans.factory.annotation.Autowired;
public class EventGridConfigProvider implements IAzureResourceConfigProvider {
@Autowired
EventGridPartitionConfigAdapter adapter;
@Override
public EventGridPartitionConfig getConfig(String dataPartitionId) {
return adapter.getConfig(dataPartitionId);
}
}
package org.opengroup.osdu.azure.partition.providers;
import org.opengroup.osdu.azure.partition.models.IAzureResourcePartitionConfig;
import org.springframework.context.annotation.Configuration;
@Configuration
public interface IAzureResourceConfigProvider {
public IAzureResourcePartitionConfig getConfig(String dataPartitionId);
}
......@@ -12,9 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package org.opengroup.osdu.azure.partition.adapters;
package org.opengroup.osdu.azure.partition.providers;
import org.opengroup.osdu.azure.partition.models.IAzureResourcePartitionConfig;
import org.opengroup.osdu.azure.util.AzureServicePrincipleTokenService;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.partition.IPartitionFactory;
......@@ -22,11 +21,10 @@ import org.opengroup.osdu.core.common.partition.IPartitionProvider;
import org.opengroup.osdu.core.common.partition.PartitionException;
import org.opengroup.osdu.core.common.partition.PartitionInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
Abstract class that extends the functionality of getting Partition Info.
*/
public abstract class AzureResourcePartitionConfigAdapter implements IAzureResourcePartitionConfigAdapter {
@Component
public class PartitionInfoProvider {
@Autowired
private DpsHeaders headers;
@Autowired
......@@ -34,10 +32,7 @@ public abstract class AzureResourcePartitionConfigAdapter implements IAzureResou
@Autowired
private IPartitionFactory partitionFactory;
/**
* dummy.
*/
public abstract IAzureResourcePartitionConfig getConfig(String partitionId);
// TODO: @komakkar check if this can be cached. The only downside will be failing calls everytime a new config is added and we try to access it.
/**
* Get partition info.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment