Skip to content

Commit

Permalink
KAA-749: Fixes to Java SDK generation and filter cache invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvayka committed Feb 4, 2016
1 parent 57fc90f commit da7844e
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public interface NotificationListener {
* @param notification the notification object.
*
*/
void onNotification(String topicId, ${notification_class} notification);
void onNotification(long topicId, ${notification_class} notification);

}
1 change: 0 additions & 1 deletion server/common/dao/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<systemPropertyVariables>
<server_log_dir>./logs</server_log_dir>
Expand Down
5 changes: 4 additions & 1 deletion server/common/dao/src/main/resources/common-dao-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<context:annotation-config/>
<aop:aspectj-autoproxy />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
import java.util.Collections;
import java.util.List;

import static org.kaaproject.kaa.common.dto.Util.getArrayCopy;

public class EndpointProfileDto implements HasId, HasVersion, Serializable {


private static final List<EndpointGroupStateDto> EMPTY_GROUP_STATE = Collections.unmodifiableList(new ArrayList<>());
private static final List<EndpointGroupStateDto> EMPTY_GROUP_STATE = Collections.unmodifiableList(new ArrayList<EndpointGroupStateDto>());

private static final long serialVersionUID = -7122736699758720540L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public final class AppProfileVersionsKey implements Serializable {
private final String applicationToken;

/** The version. */
private final int endpointProfileSchemaVersion;
private final Integer endpointProfileSchemaVersion;

/** The version. */
private final int serverProfileSchemaVersion;
private final Integer serverProfileSchemaVersion;

/**
* Instantiates a new app version key.
Expand All @@ -49,7 +49,7 @@ public final class AppProfileVersionsKey implements Serializable {
* @param serverProfileSchemaVersion
* the server profile schema version
*/
public AppProfileVersionsKey(String applicationToken, int endpointProfileSchemaVersion, int serverProfileSchemaVersion) {
public AppProfileVersionsKey(String applicationToken, Integer endpointProfileSchemaVersion, Integer serverProfileSchemaVersion) {
super();
this.applicationToken = applicationToken;
this.endpointProfileSchemaVersion = endpointProfileSchemaVersion;
Expand All @@ -60,11 +60,11 @@ public String getApplicationToken() {
return applicationToken;
}

public int getEndpointProfileSchemaVersion() {
public Integer getEndpointProfileSchemaVersion() {
return endpointProfileSchemaVersion;
}

public int getServerProfileSchemaVersion() {
public Integer getServerProfileSchemaVersion() {
return serverProfileSchemaVersion;
}

Expand All @@ -73,29 +73,44 @@ public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((applicationToken == null) ? 0 : applicationToken.hashCode());
result = prime * result + endpointProfileSchemaVersion;
result = prime * result + serverProfileSchemaVersion;
result = prime * result + ((endpointProfileSchemaVersion == null) ? 0 : endpointProfileSchemaVersion.hashCode());
result = prime * result + ((serverProfileSchemaVersion == null) ? 0 : serverProfileSchemaVersion.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;
}
AppProfileVersionsKey other = (AppProfileVersionsKey) obj;
if (applicationToken == null) {
if (other.applicationToken != null)
if (other.applicationToken != null) {
return false;
} else if (!applicationToken.equals(other.applicationToken))
}
} else if (!applicationToken.equals(other.applicationToken)) {
return false;
if (endpointProfileSchemaVersion != other.endpointProfileSchemaVersion)
}
if (endpointProfileSchemaVersion == null) {
if (other.endpointProfileSchemaVersion != null) {
return false;
}
} else if (!endpointProfileSchemaVersion.equals(other.endpointProfileSchemaVersion)) {
return false;
if (serverProfileSchemaVersion != other.serverProfileSchemaVersion)
}
if (serverProfileSchemaVersion == null) {
if (other.serverProfileSchemaVersion != null) {
return false;
}
} else if (!serverProfileSchemaVersion.equals(other.serverProfileSchemaVersion)) {
return false;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,23 @@ public void sendUserConfigurationUpdates(List<UserConfigurationUpdate> updates)
*/
private void processCacheNotification(Notification notification) {
ApplicationDto appDto = applicationService.findAppById(notification.getAppId());
LOG.debug("Processing cache notification {} for app {}", notification, appDto);
if (appDto != null) {
if (notification.getProfileFilterId() != null) {
ProfileFilterDto filterDto = cacheService.getFilter(notification.getProfileFilterId());
LOG.debug("Processing filter {}", filterDto);
if (filterDto.getEndpointProfileSchemaId() != null && filterDto.getServerProfileSchemaId() != null) {
cacheService.resetFilters(new AppProfileVersionsKey(appDto.getApplicationToken(), filterDto
.getEndpointProfileSchemaVersion(), filterDto.getServerProfileSchemaVersion()));
} else if (filterDto.getServerProfileSchemaVersion() == null) {
for (VersionDto version : profileService.findProfileSchemaVersionsByAppId(appDto.getId())) {
cacheService.resetFilters(new AppProfileVersionsKey(appDto.getApplicationToken(), version.getVersion(), filterDto
.getServerProfileSchemaVersion()));
LOG.debug("Processing version {}", version);
cacheService.resetFilters(new AppProfileVersionsKey(appDto.getApplicationToken(), version.getVersion(), null));
}
} else {
for (ServerProfileSchemaDto version : serverProfileService.findServerProfileSchemasByAppId(appDto.getId())) {
cacheService.resetFilters(new AppProfileVersionsKey(appDto.getApplicationToken(), version.getVersion(), filterDto
.getServerProfileSchemaVersion()));
LOG.debug("Processing version {}", version);
cacheService.resetFilters(new AppProfileVersionsKey(appDto.getApplicationToken(), null, version.getVersion()));
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions server/node/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@

<logger name="org.kaaproject.kaa" level="INFO"/>
<logger name="org.kaaproject.kaa.metrics" level="WARN"/>
<logger name="org.kaaproject.kaa.server" level="INFO"/>
<logger name="org.kaaproject.kaa.server.node" level="INFO"/>
<logger name="org.kaaproject.kaa.server.admin" level="INFO"/>
<logger name="org.kaaproject.kaa.server.control" level="INFO"/>
<logger name="org.kaaproject.kaa.server.bootstrap" level="INFO"/>
<logger name="org.kaaproject.kaa.server.operations" level="INFO"/>
<logger name="org.kaaproject.kaa.server" level="TRACE"/>
<logger name="org.kaaproject.kaa.server.hash" level="WARN"/>
<logger name="org.kaaproject.kaa.server.bootstrap.service.DefaultOperationsServerListService" level="WARN"/>
<logger name="org.kaaproject.kaa.server.operations.service.statistics" level="WARN"/>
<logger name="org.kaaproject.kaa.server.operations.service.event" level="WARN"/>
<logger name="org.kaaproject.kaa.server.thrift" level="WARN"/>
Expand Down
4 changes: 2 additions & 2 deletions server/node/src/test/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
</encoder>
</appender>

<logger name="org.kaaproject.kaa" level="INFO"/>
<logger name="org.kaaproject.kaa" level="TRACE"/>
<logger name="org.kaaproject.kaa.metrics" level="WARN"/>
<logger name="org.kaaproject.kaa.server" level="INFO"/>
<logger name="org.kaaproject.kaa.server" level="DEBUG"/>
<logger name="org.kaaproject.kaa.server.node" level="INFO"/>
<logger name="org.kaaproject.kaa.server.admin" level="INFO"/>
<logger name="org.kaaproject.kaa.server.control" level="INFO"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.FullHttpResponse;
Expand All @@ -34,7 +36,9 @@
import io.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataType;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.security.GeneralSecurityException;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.codec.binary.Base64;
Expand Down Expand Up @@ -189,10 +193,13 @@ public void setResponseSignature(byte[] responseSignature) {
public HttpResponse getResponse() {
LOG.trace("CommandName: " + COMMAND_NAME + ": getHttpResponse..");

FullHttpResponse httpResponse = new DefaultFullHttpResponse(HTTP_1_1, OK, Unpooled.copiedBuffer(responseBody));
ByteBuf data = Unpooled.copiedBuffer(responseBody);
LOG.warn("Response data: {}" , Arrays.toString(data.array()));
FullHttpResponse httpResponse = new DefaultFullHttpResponse(HTTP_1_1, OK, data);

httpResponse.headers().set(CONTENT_TYPE, CommonEPConstans.RESPONSE_CONTENT_TYPE);
httpResponse.headers().set(CONTENT_LENGTH, httpResponse.content().readableBytes());
httpResponse.headers().set(CONTENT_LENGTH, data.readableBytes());
LOG.warn("Response size: {}" , data.readableBytes());
httpResponse.headers().set(CommonEPConstans.RESPONSE_TYPE, CommonEPConstans.RESPONSE_TYPE_OPERATION);
if(responseSignature != null){
httpResponse.headers().set(CommonEPConstans.SIGNATURE_HEADER_NAME, Base64.encodeBase64String(responseSignature));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
public class ResponseEncoder extends ChannelOutboundHandlerAdapter {

private static final Logger LOG = LoggerFactory.getLogger(RequestDecoder.class);
private static final Logger LOG = LoggerFactory.getLogger(ResponseEncoder.class);

@Override
public void write(ChannelHandlerContext ctx, Object msg,
Expand Down

0 comments on commit da7844e

Please sign in to comment.