Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
feat(search): synchronize search indexes across management instances
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGeraud committed May 10, 2019
1 parent dd76488 commit 13818d6
Show file tree
Hide file tree
Showing 25 changed files with 1,028 additions and 21 deletions.
@@ -0,0 +1,71 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.management.model.command;

import java.util.List;

/**
* @author Nicolas GERAUD (nicolas.geraud at graviteesource.com)
* @author GraviteeSource Team
*/
public class CommandEntity {

private String id;
private String to;
private List<CommandTags> tags;
private String content;
private long ttlInSeconds;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getTo() {
return to;
}

public void setTo(String to) {
this.to = to;
}

public List<CommandTags> getTags() {
return tags;
}

public void setTags(List<CommandTags> tags) {
this.tags = tags;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public long getTtlInSeconds() {
return ttlInSeconds;
}

public void setTtlInSeconds(long ttlInSeconds) {
this.ttlInSeconds = ttlInSeconds;
}
}
@@ -0,0 +1,44 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.management.model.command;

import java.util.List;

/**
* @author Nicolas GERAUD (nicolas.geraud at graviteesource.com)
* @author GraviteeSource Team
*/
public class CommandQuery {

private String to;
private List<CommandTags> tags;

public String getTo() {
return to;
}

public void setTo(String to) {
this.to = to;
}

public List<CommandTags> getTags() {
return tags;
}

public void setTags(List<CommandTags> tags) {
this.tags = tags;
}
}
@@ -0,0 +1,60 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.management.model.command;

/**
* @author Nicolas GERAUD (nicolas.geraud at graviteesource.com)
* @author GraviteeSource Team
*/
public class CommandSearchIndexerEntity {

private String id;
private String clazz;
private String action;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getClazz() {
return clazz;
}

public void setClazz(String clazz) {
this.clazz = clazz;
}

public String getAction() {
return action;
}

public void setAction(String action) {
this.action = action;
}

@Override
public String toString() {
return "CommandSearchIndexerEntity{" +
"id='" + id + '\'' +
", clazz='" + clazz + '\'' +
", action='" + action + '\'' +
'}';
}
}
@@ -0,0 +1,25 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.management.model.command;

/**
* @author Nicolas GERAUD (nicolas.geraud at graviteesource.com)
* @author GraviteeSource Team
*/

public enum CommandTags {
DATA_TO_INDEX
}
@@ -0,0 +1,62 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.management.model.command;

import java.util.List;

/**
* @author Nicolas GERAUD (nicolas.geraud at graviteesource.com)
* @author GraviteeSource Team
*/
public class NewCommandEntity {

private String to;
private List<CommandTags> tags;
private String content;
private long ttlInSeconds;

public String getTo() {
return to;
}

public void setTo(String to) {
this.to = to;
}

public List<CommandTags> getTags() {
return tags;
}

public void setTags(List<CommandTags> tags) {
this.tags = tags;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public long getTtlInSeconds() {
return ttlInSeconds;
}

public void setTtlInSeconds(long ttlInSeconds) {
this.ttlInSeconds = ttlInSeconds;
}
}
Expand Up @@ -17,7 +17,9 @@

/**
* @author David BRASSELY (david.brassely at graviteesource.com)
* @author Nicolas GERAUD (nicolas.geraud at graviteesource.com)
* @author GraviteeSource Team
*/
public interface Indexable {
String getId();
}
@@ -0,0 +1,56 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.management.repository.proxy;

import io.gravitee.repository.exceptions.TechnicalException;
import io.gravitee.repository.management.api.CommandRepository;
import io.gravitee.repository.management.api.search.CommandCriteria;
import io.gravitee.repository.management.model.Command;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Optional;

/**
* @author Nicolas GERAUD (nicolas.geraud at graviteesource.com)
* @author GraviteeSource Team
*/
@Component
public class CommandRepositoryProxy extends AbstractProxy<CommandRepository> implements CommandRepository {
@Override
public Optional<Command> findById(String id) throws TechnicalException {
return target.findById(id);
}

@Override
public Command create(Command command) throws TechnicalException {
return target.create(command);
}

@Override
public Command update(Command command) throws TechnicalException {
return target.update(command); }

@Override
public void delete(String id) throws TechnicalException {
target.delete(id);
}

@Override
public List<Command> search(CommandCriteria criteria) {
return target.search(criteria);
}
}
6 changes: 5 additions & 1 deletion gravitee-management-api-service/pom.xml
Expand Up @@ -228,5 +228,9 @@
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>io.gravitee.node</groupId>
<artifactId>gravitee-node-api</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,33 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.management.service;

import io.gravitee.management.model.command.CommandEntity;
import io.gravitee.management.model.command.CommandQuery;
import io.gravitee.management.model.command.NewCommandEntity;

import java.util.List;

/**
* @author Nicolas GERAUD (nicolas.geraud at graviteesource.com)
* @author GraviteeSource Team
*/
public interface CommandService {

void send(NewCommandEntity message);
List<CommandEntity> search(CommandQuery query);
void ack(String messageId);
}

0 comments on commit 13818d6

Please sign in to comment.