Improvements to SettingsInfo.

This commit is contained in:
Simone Bordet 2012-02-23 17:58:35 +01:00
parent 726fda5593
commit 4bcd7548d9
4 changed files with 30 additions and 8 deletions

View File

@ -75,8 +75,10 @@ public class SettingsInfo
public static final int UPLOAD_BANDWIDTH = 1; public static final int UPLOAD_BANDWIDTH = 1;
public static final int DOWNLOAD_BANDWIDTH = 2; public static final int DOWNLOAD_BANDWIDTH = 2;
public static final int ROUND_TRIP_TIME = 3; public static final int ROUND_TRIP_TIME = 3;
public static final int MAX_STREAMS = 4; public static final int MAX_CONCURRENT_STREAMS = 4;
public static final int CONGESTION_WINDOW = 5; public static final int CURRENT_CONGESTION_WINDOW = 5;
public static final int DOWNLOAD_RETRANSMISSION_RATE = 6;
public static final int INITIAL_WINDOW_SIZE = 7;
public static final int FLAG_PERSIST = 1 << 24; public static final int FLAG_PERSIST = 1 << 24;
public static final int FLAG_PERSISTED = 2 << 24; public static final int FLAG_PERSISTED = 2 << 24;
@ -136,4 +138,8 @@ public class SettingsInfo
return "[" + getFlags() + "," + getId() + "]"; return "[" + getFlags() + "," + getId() + "]";
} }
} }
public static class Setting
{
}
} }

View File

@ -66,9 +66,7 @@ public class SettingsBodyParser extends ControlFrameBodyParser
--cursor; --cursor;
count += (currByte & 0xFF) << 8 * cursor; count += (currByte & 0xFF) << 8 * cursor;
if (cursor == 0) if (cursor == 0)
{
state = State.KEY; state = State.KEY;
}
break; break;
} }
case KEY: case KEY:

View File

@ -35,7 +35,7 @@ public class SettingsGenerateParseTest
{ {
byte flags = SettingsInfo.CLEAR_PERSISTED; byte flags = SettingsInfo.CLEAR_PERSISTED;
Map<SettingsInfo.Key, Integer> pairs = new HashMap<>(); Map<SettingsInfo.Key, Integer> pairs = new HashMap<>();
pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.MAX_STREAMS), 100); pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.MAX_CONCURRENT_STREAMS), 100);
pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSISTED | SettingsInfo.Key.ROUND_TRIP_TIME), 500); pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSISTED | SettingsInfo.Key.ROUND_TRIP_TIME), 500);
SettingsFrame frame1 = new SettingsFrame(SPDY.V2, flags, pairs); SettingsFrame frame1 = new SettingsFrame(SPDY.V2, flags, pairs);
Generator generator = new Generator(new StandardCompressionFactory().newCompressor()); Generator generator = new Generator(new StandardCompressionFactory().newCompressor());
@ -62,7 +62,7 @@ public class SettingsGenerateParseTest
{ {
byte flags = SettingsInfo.CLEAR_PERSISTED; byte flags = SettingsInfo.CLEAR_PERSISTED;
Map<SettingsInfo.Key, Integer> pairs = new HashMap<>(); Map<SettingsInfo.Key, Integer> pairs = new HashMap<>();
pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.MAX_STREAMS), 100); pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.MAX_CONCURRENT_STREAMS), 100);
pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSISTED | SettingsInfo.Key.ROUND_TRIP_TIME), 500); pairs.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSISTED | SettingsInfo.Key.ROUND_TRIP_TIME), 500);
SettingsFrame frame1 = new SettingsFrame(SPDY.V2, flags, pairs); SettingsFrame frame1 = new SettingsFrame(SPDY.V2, flags, pairs);
Generator generator = new Generator(new StandardCompressionFactory().newCompressor()); Generator generator = new Generator(new StandardCompressionFactory().newCompressor());

View File

@ -36,7 +36,7 @@ public class SettingsTest extends AbstractTest
Map<SettingsInfo.Key,Integer> settings = new HashMap<>(); Map<SettingsInfo.Key,Integer> settings = new HashMap<>();
settings.put(new SettingsInfo.Key(SettingsInfo.Key.UPLOAD_BANDWIDTH), 1024 * 1024); settings.put(new SettingsInfo.Key(SettingsInfo.Key.UPLOAD_BANDWIDTH), 1024 * 1024);
settings.put(new SettingsInfo.Key(SettingsInfo.Key.DOWNLOAD_BANDWIDTH), 1024 * 1024); settings.put(new SettingsInfo.Key(SettingsInfo.Key.DOWNLOAD_BANDWIDTH), 1024 * 1024);
settings.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSISTED | SettingsInfo.Key.CONGESTION_WINDOW), 1024); settings.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSISTED | SettingsInfo.Key.CURRENT_CONGESTION_WINDOW), 1024);
final SettingsInfo clientSettingsInfo = new SettingsInfo(settings); final SettingsInfo clientSettingsInfo = new SettingsInfo(settings);
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
ServerSessionFrameListener serverSessionFrameListener = new ServerSessionFrameListener.Adapter() ServerSessionFrameListener serverSessionFrameListener = new ServerSessionFrameListener.Adapter()
@ -61,7 +61,7 @@ public class SettingsTest extends AbstractTest
Map<SettingsInfo.Key,Integer> settings = new HashMap<>(); Map<SettingsInfo.Key,Integer> settings = new HashMap<>();
settings.put(new SettingsInfo.Key(SettingsInfo.Key.UPLOAD_BANDWIDTH), 1024 * 1024); settings.put(new SettingsInfo.Key(SettingsInfo.Key.UPLOAD_BANDWIDTH), 1024 * 1024);
settings.put(new SettingsInfo.Key(SettingsInfo.Key.DOWNLOAD_BANDWIDTH), 1024 * 1024); settings.put(new SettingsInfo.Key(SettingsInfo.Key.DOWNLOAD_BANDWIDTH), 1024 * 1024);
settings.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.CONGESTION_WINDOW), 1024); settings.put(new SettingsInfo.Key(SettingsInfo.Key.FLAG_PERSIST | SettingsInfo.Key.CURRENT_CONGESTION_WINDOW), 1024);
final SettingsInfo serverSettingsInfo = new SettingsInfo(settings); final SettingsInfo serverSettingsInfo = new SettingsInfo(settings);
ServerSessionFrameListener serverSessionFrameListener = new ServerSessionFrameListener.Adapter() ServerSessionFrameListener serverSessionFrameListener = new ServerSessionFrameListener.Adapter()
{ {
@ -87,4 +87,22 @@ public class SettingsTest extends AbstractTest
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
} }
@Test
public void test() throws Exception
{
startServer(new ServerSessionFrameListener.Adapter()
{
@Override
public void onConnect(Session session)
{
Map<SettingsInfo.Key, Integer> settings = new HashMap<>();
settings.put(new SettingsInfo.Key(0x01_00_00_04), 25);
settings.put(new SettingsInfo.Key(0x00_00_07_00), 49152);
SettingsInfo settingsInfo = new SettingsInfo(settings, true);
session.settings(settingsInfo);
}
});
new CountDownLatch(1).await();
}
} }