You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2018/03/01 22:20:49 UTC
[incubator-pulsar] branch master updated: Remove deprecated
newConnect methods (#1315)
This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new ccf1812 Remove deprecated newConnect methods (#1315)
ccf1812 is described below
commit ccf1812da9f9280ef829527d3a97ee23c4ad3691
Author: Dave Rusek <da...@gmail.com>
AuthorDate: Thu Mar 1 15:20:46 2018 -0700
Remove deprecated newConnect methods (#1315)
* Remove deprecated and unused code
* Revert "Remove deprecated and unused code"
This reverts commit 95114c6f573cd8ef26bc2c3c0ad2691a1af6f268.
* Move old newConnect funtions to tests for backward compat
---
.../pulsar/broker/service/ServerCnxTest.java | 23 +++++++++++++--
.../org/apache/pulsar/common/api/Commands.java | 34 ++++------------------
2 files changed, 26 insertions(+), 31 deletions(-)
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java
index 486f1cd..6158495 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java
@@ -58,6 +58,7 @@ import org.apache.bookkeeper.mledger.ManagedLedgerConfig;
import org.apache.bookkeeper.mledger.ManagedLedgerException;
import org.apache.bookkeeper.mledger.ManagedLedgerFactory;
import org.apache.bookkeeper.mledger.impl.PositionImpl;
+import org.apache.bookkeeper.tools.cli.helpers.Command;
import org.apache.pulsar.broker.PulsarService;
import org.apache.pulsar.broker.ServiceConfiguration;
import org.apache.pulsar.broker.admin.AdminResource;
@@ -75,6 +76,7 @@ import org.apache.pulsar.common.api.ByteBufPair;
import org.apache.pulsar.common.api.Commands;
import org.apache.pulsar.common.api.Commands.ChecksumType;
import org.apache.pulsar.common.api.PulsarHandler;
+import org.apache.pulsar.common.api.proto.PulsarApi;
import org.apache.pulsar.common.api.proto.PulsarApi.AuthMethod;
import org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.AckType;
import org.apache.pulsar.common.api.proto.PulsarApi.CommandConnected;
@@ -210,6 +212,24 @@ public class ServerCnxTest {
channel.finish();
}
+ private static ByteBuf newConnect(AuthMethod authMethod, String authData, int protocolVersion) {
+ PulsarApi.CommandConnect.Builder connectBuilder = PulsarApi.CommandConnect.newBuilder();
+ connectBuilder.setClientVersion("Pulsar Client");
+ connectBuilder.setAuthMethod(authMethod);
+ connectBuilder.setAuthData(ByteString.copyFromUtf8(authData));
+ connectBuilder.setProtocolVersion(protocolVersion);
+ PulsarApi.CommandConnect connect = connectBuilder.build();
+ ByteBuf res = Commands.serializeWithSize(PulsarApi.BaseCommand.newBuilder().setType(PulsarApi.BaseCommand.Type.CONNECT).setConnect(connect));
+ connect.recycle();
+ connectBuilder.recycle();
+ return res;
+ }
+
+ /**
+ * Ensure that old clients may still connect to new servers
+ *
+ * @throws Exception
+ */
@Test(timeOut = 30000)
public void testConnectCommandWithEnum() throws Exception {
resetChannel();
@@ -217,8 +237,7 @@ public class ServerCnxTest {
assertEquals(serverCnx.getState(), State.Start);
// test server response to CONNECT
- @SuppressWarnings("deprecation") // We're actually testing that the deprecated method still works
- ByteBuf clientCommand = Commands.newConnect(AuthMethod.AuthMethodNone, "");
+ ByteBuf clientCommand = newConnect(AuthMethod.AuthMethodNone, "", Commands.getCurrentProtocolVersion());
channel.writeInbound(clientCommand);
assertEquals(serverCnx.getState(), State.Connected);
diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/api/Commands.java b/pulsar-common/src/main/java/org/apache/pulsar/common/api/Commands.java
index 073de6b..b51d29e 100644
--- a/pulsar-common/src/main/java/org/apache/pulsar/common/api/Commands.java
+++ b/pulsar-common/src/main/java/org/apache/pulsar/common/api/Commands.java
@@ -21,6 +21,7 @@ package org.apache.pulsar.common.api;
import static com.scurrilous.circe.checksum.Crc32cIntChecksum.computeChecksum;
import static com.scurrilous.circe.checksum.Crc32cIntChecksum.resumeChecksum;
+import com.google.common.annotations.VisibleForTesting;
import com.google.protobuf.ByteString;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
@@ -136,33 +137,6 @@ public class Commands {
return res;
}
- /**
- * @deprecated AuthMethod has been deprecated. Use {@link #newConnect(String authMethodName, String authData)}
- * instead.
- */
- @Deprecated
- public static ByteBuf newConnect(AuthMethod authMethod, String authData) {
- return newConnect(authMethod, authData, getCurrentProtocolVersion());
- }
-
- /**
- * @deprecated AuthMethod has been deprecated. Use
- * {@link #newConnect(String authMethodName, String authData, int protocolVersion)} instead.
- */
- @Deprecated
- public static ByteBuf newConnect(AuthMethod authMethod, String authData, int protocolVersion) {
- CommandConnect.Builder connectBuilder = CommandConnect.newBuilder();
- connectBuilder.setClientVersion("Pulsar Client");
- connectBuilder.setAuthMethod(authMethod);
- connectBuilder.setAuthData(ByteString.copyFromUtf8(authData));
- connectBuilder.setProtocolVersion(protocolVersion);
- CommandConnect connect = connectBuilder.build();
- ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.CONNECT).setConnect(connect));
- connect.recycle();
- connectBuilder.recycle();
- return res;
- }
-
public static ByteBuf newConnected(int clientProtocolVersion) {
CommandConnected.Builder connectedBuilder = CommandConnected.newBuilder();
connectedBuilder.setServerVersion("Pulsar Server");
@@ -702,7 +676,8 @@ public class Commands {
return res;
}
- private static ByteBuf serializeWithSize(BaseCommand.Builder cmdBuilder) {
+ @VisibleForTesting
+ public static ByteBuf serializeWithSize(BaseCommand.Builder cmdBuilder) {
// / Wire format
// [TOTAL_SIZE] [CMD_SIZE][CMD]
BaseCommand cmd = cmdBuilder.build();
@@ -941,7 +916,8 @@ public class Commands {
return (ByteBufPair) ByteBufPair.get(headers, metadataAndPayload);
}
- private static int getCurrentProtocolVersion() {
+ @VisibleForTesting
+ public static int getCurrentProtocolVersion() {
// Return the last ProtocolVersion enum value
return ProtocolVersion.values()[ProtocolVersion.values().length - 1].getNumber();
}
--
To stop receiving notification emails like this one, please contact
mmerli@apache.org.