This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.*; | |
import org.apache.ignite.cache.query.annotations.QuerySqlField; | |
//Sample job model | |
@Builder | |
@Getter | |
@Setter | |
@ToString | |
@EqualsAndHashCode | |
public class Job { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.ignite.Ignite; | |
import org.apache.ignite.cache.CacheInterceptorAdapter; | |
import org.apache.ignite.cluster.ClusterNode; | |
import org.apache.ignite.resources.IgniteInstanceResource; | |
import org.jetbrains.annotations.Nullable; | |
import javax.cache.Cache; | |
import static com.romeh.failover.demo.CacheNames.ICEP_JOBS; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mport org.apache.ignite.Ignite; | |
import org.apache.ignite.IgniteCache; | |
import org.apache.ignite.cache.CacheInterceptorAdapter; | |
import org.apache.ignite.cache.query.SqlQuery; | |
import org.apache.ignite.cluster.ClusterNode; | |
import org.apache.ignite.resources.IgniteInstanceResource; | |
import org.jetbrains.annotations.Nullable; | |
import javax.cache.Cache; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
_________ _____ __________________ _____ | |
__ ____/___________(_)______ /__ ____/______ ____(_)_______ | |
_ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \ | |
/ /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / / | |
\____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.ignite.*; | |
import org.apache.ignite.events.DiscoveryEvent; | |
import org.apache.ignite.events.EventType; | |
import javax.cache.expiry.CreatedExpiryPolicy; | |
import javax.cache.expiry.Duration; | |
public class NodeApp { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Builder | |
@Getter | |
@Setter | |
@ToString | |
@EqualsAndHashCode | |
public class AlertEntry implements Serializable { | |
@ApiModelProperty(notes = "the key value alert content for error description required to be entered by user into REST API ", required = true) | |
@NotNull | |
private Map<String,String> alertContent; | |
@ApiModelProperty(notes = "alert error code required to be entered by user into REST API ", required = true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class AlertManagerConfiguration { | |
@Value("${mail.service.baseUrl}") | |
private String baseUrl; | |
@Value("${mail.service.user}") | |
private String user; | |
@Value("${mail.service.password}") | |
private String password; | |
@Value("${enableFilePersistence}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void updateAlertEntry(String serviceId, String serviceCode, AlertEntry alertEntry) { | |
final IgniteCache<String, AlertEntry> alertsCache = getAlertsCache(); | |
// update the alert entry via cache invoke for atomicity | |
alertsCache.invoke(alertEntry.getAlertId(), (mutableEntry, objects) -> { | |
if (mutableEntry.exists() && mutableEntry.getValue() != null) { | |
logger.debug("updating alert entry into the cache store invoke: {},{}", serviceId, serviceCode); | |
mutableEntry.setValue(alertEntry); | |
} else { | |
throw new ResourceNotFoundException(String.format("Alert for %s with %s not found", serviceId, serviceCode)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public List<AlertEntry> getAlertForServiceId(String serviceId) { | |
final String sql = "serviceId = ?"; | |
// create the sql query object with entity type of the value part of the key value cache | |
SqlQuery<String, AlertEntry> query = new SqlQuery<>(AlertEntry.class, sql); | |
// set the query params | |
query.setArgs(serviceId); | |
//then execute it over the cache | |
return Optional.ofNullable(getAlertsCache().query(query).getAll().stream().map(stringAlertEntryEntry -> stringAlertEntryEntry.getValue()).collect(Collectors.toList())) | |
.orElseThrow(() -> new ResourceNotFoundException(String.format("Alert for %s not found", serviceId))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// durable file memory persistence | |
if(enableFilePersistence){ | |
PersistentStoreConfiguration persistentStoreConfiguration = new PersistentStoreConfiguration(); | |
persistentStoreConfiguration.setPersistentStorePath("./data/store"); | |
persistentStoreConfiguration.setWalArchivePath("./data/walArchive"); | |
persistentStoreConfiguration.setWalStorePath("./data/walStore"); | |
igniteConfiguration.setPersistentStoreConfiguration(persistentStoreConfiguration); | |
} |
OlderNewer