• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ImmutableValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.msgpack.value.ImmutableValue的典型用法代码示例。如果您正苦于以下问题:Java ImmutableValue类的具体用法?Java ImmutableValue怎么用?Java ImmutableValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ImmutableValue类属于org.msgpack.value包,在下文中一共展示了ImmutableValue类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: unpackBigNumber

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
public BigInteger unpackBigNumber() throws IOException {
    ImmutableValue value = this.unpackValue();
    if (!value.isExtensionValue())
        throw new RuntimeException("Expected extension value");

    ExtensionValue extValue = value.asExtensionValue();
    if (extValue.getType() != 0)
        throw new RuntimeException("Expected bignum value");

    byte[] data = extValue.getData();
    byte sign = data[0];
    if (sign != '+' && sign != '-')
        throw new RuntimeException("Sign was not pos or neg");

    BigInteger bn = new BigInteger(sign == '+' ? 1 : -1, Arrays.copyOfRange(data, 1, data.length));
    return bn;
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:18,代码来源:Unpacker.java


示例2: deserialize

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
@Override
public <T> T deserialize( ModuleDescriptor module, ValueType valueType, InputStream state )
{
    try( MessageUnpacker unpacker = MessagePack.newDefaultUnpacker( state ) )
    {
        if( !unpacker.hasNext() )
        {
            return null;
        }
        ImmutableValue value = unpacker.unpackValue();
        return doDeserialize( module, valueType, value );
    }
    catch( IOException ex )
    {
        throw new SerializationException( "Unable to deserialize " + valueType, ex );
    }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:18,代码来源:MessagePackDeserializer.java


示例3: Complete

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
Complete(final ImmutableValue value) {
  this.value = value;
}
 
开发者ID:okumin,项目名称:influent,代码行数:4,代码来源:DecodeResult.java


示例4: value

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
@Override
ImmutableValue value() {
  return value;
}
 
开发者ID:okumin,项目名称:influent,代码行数:5,代码来源:DecodeResult.java


示例5: complete

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
static DecodeResult complete(final ImmutableValue result) {
  return new Complete(result);
}
 
开发者ID:okumin,项目名称:influent,代码行数:4,代码来源:DecodeResult.java


示例6: ConstantUnpacker

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
ConstantUnpacker(final int size, final Function<ByteBuffer, ImmutableValue> factory) {
  this.builder = ByteBuffer.allocate(size);
  this.factory = factory;
}
 
开发者ID:okumin,项目名称:influent,代码行数:5,代码来源:MsgpackIncrementalUnpacker.java


示例7: MultipleUnpacker

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
private MultipleUnpacker(final int size, final Function<ImmutableValue[], ImmutableValue> factory) {
  this.builder = new ImmutableValue[size];
  this.factory = factory;
}
 
开发者ID:okumin,项目名称:influent,代码行数:5,代码来源:MsgpackIncrementalUnpacker.java


示例8: decode

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
public CheckPingResult decode(ImmutableValue value) {
  logger.debug("decoding ping {}", value);
  if (!value.isArrayValue()) {
    error("A ping message must be an array", value);
  }
  ImmutableArrayValue arrayValue = value.asArrayValue();
  if (arrayValue.size() != 6) {
    error("A ping message must have 6 elements", value);
  }
  String ping = decodeString(arrayValue.get(0));
  if (!ping.equals(("PING"))) {
    error("Invalid ping message", value);
  }
  String clientHostname = decodeString(arrayValue.get(1));
  String sharedKeySalt = decodeString(arrayValue.get(2)); // TODO Support both String and byte[]
  String sharedKeyHexDigest = decodeString(arrayValue.get(3));
  String username = decodeString(arrayValue.get(4));
  String passwordDigest = decodeString(arrayValue.get(5));

  if (node == null && !security.isAnonymousSourceAllowed()) {
    // FIXME add remote address to message
    String message = "Anonymous client disallowed.";
    logger.warn(message);
    return CheckPingResult.failure(message);
  }

  String sharedKey = null;
  try {
    sharedKey = node != null ? node.getSharedKey() : security.getSharedKey();
    MessageDigest md = MessageDigest.getInstance("SHA-512");
    md.update(sharedKeySalt.getBytes());
    md.update(clientHostname.getBytes());
    md.update(nonce);
    md.update(sharedKey.getBytes());
    String serverSideDigest = generateHexString(md.digest());
    if (!sharedKeyHexDigest.equals(serverSideDigest)) {
      // FIXME Add remote address to log
      logger.warn("Shared key mismatch: {}", clientHostname);
      return CheckPingResult.failure("Shared key mismatch");
    }

    if (security.isUserAuthEnabled()) {
      boolean userAuthenticationSucceeded = security.findAuthenticateUsers(node, username).stream().anyMatch(user -> {
        md.reset();
        md.update(userAuth);
        md.update(username.getBytes());
        md.update(user.getPassword().getBytes());
        String serverSidePasswordDigest = generateHexString(md.digest());
        return passwordDigest.equals(serverSidePasswordDigest);
      });
      if (!userAuthenticationSucceeded) {
        // FIXME Add remote address to log
        logger.info("Authentication failed: hostname={}, username={}", clientHostname, username);
        return CheckPingResult.failure("username/password mismatch");
      }
    }
  } catch (NoSuchAlgorithmException e) {
    error(e.getMessage(), value, e);
  }

  return CheckPingResult.success(sharedKeySalt, sharedKey);
}
 
开发者ID:okumin,项目名称:influent,代码行数:63,代码来源:MsgPackPingDecoder.java


示例9: decode

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
/**
 * Decodes a request from clients.
 *
 * {@see https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v1}
 *
 * {{{
 *   Connection ::= <<Request>>*
 *   Request ::= Message | Forward | PackedForward | nil
 *   Message ::= [ Tag, Time, Record, Option? ]
 *   Forward ::= [ Tag, MultiEventStream, Option? ]
 *   MultiEventStream ::= [ Event* ]
 *   PackedForward ::= [ Tag, MessagePackEventStream, Option? ]
 *   MessagePackEventStream ::= <<Event>>*
 *   Event ::= [ Time, Record ]
 *   Tag ::= string
 *   Time ::= integer | EventTime
 *   Record ::= object
 *   Option ::= object
 * }}}
 *
 * @param value msgpack value
 * @return {@code ForwardRequest} if {@code value} is a forward request,
 *         {@code Optional.empty()} if {@code value} is nil that is a future heartbeat request
 */
Optional<ForwardRequest> decode(final ImmutableValue value) {
  if (value.isNilValue()) return Optional.empty(); // reserved

  if (!value.isArrayValue()) {
    throw error("A request must be an array.", value);
  }
  final ImmutableArrayValue message = value.asArrayValue();

  if (message.size() < 2) {
    throw error("The size of array is too small.", value);
  }

  final Tag tag = decodeTag(message.get(0));

  final Value second = message.get(1);
  final List<EventEntry> entries;
  ForwardOption option = ForwardOption.empty();
  // TODO: CompressedPackedForward
  if (second.isArrayValue()) {
    entries = decodeMultiEventStream(second.asArrayValue());
    if (message.size() > 2) {
      option = decodeOption(message.get(2));
    }
  } else if (second.isStringValue() || second.isBinaryValue()) {
    entries = decodeMessagePackEventStream(second.asRawValue());
    if (message.size() > 2) {
      option = decodeOption(message.get(2));
    }
  } else {
    if (message.size() < 3) {
      throw error("The size of array is too small.", value);
    }
    final Instant time = decodeTime(second);
    final ImmutableMapValue record = decodeRecord(message.get(2));
    entries = Collections.singletonList(EventEntry.of(time, record));
    if (message.size() > 3) {
      option = decodeOption(message.get(3));
    }
  }

  return Optional.of(ForwardRequest.of(EventStream.of(tag, entries), option));
}
 
开发者ID:okumin,项目名称:influent,代码行数:67,代码来源:MsgpackForwardRequestDecoder.java


示例10: analyzeResult

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
private void analyzeResult(String tag, ImmutableValue timestamp, Map<String, Object> data, long start, long end, boolean eventTime)
{
    Integer count = tagCounts.get(tag);
    if (count == null) {
        count = 0;
    }
    tagCounts.put(tag, count + 1);

    if (eventTime) {
        assertThat(timestamp.isExtensionValue(), is(true));
        ExtensionValue tsInEventTime = timestamp.asExtensionValue();
        assertThat(tsInEventTime.getType(), CoreMatchers.is((byte) 0x00));
        ByteBuffer secondsAndNanoSeconds = ByteBuffer.wrap(tsInEventTime.getData());
        int seconds = secondsAndNanoSeconds.getInt();
        int nanoSeconds = secondsAndNanoSeconds.getInt();
        assertTrue(start / 1000 <= seconds && seconds <= end / 1000);
        assertThat(nanoSeconds, is(999999999));
    }
    else {
        assertThat(timestamp.isIntegerValue(), is(true));
        long tsInEpochMilli = timestamp.asIntegerValue().asLong();
        assertTrue(start <= tsInEpochMilli && tsInEpochMilli<= end);
    }

    assertEquals(3, data.size());
    String name = (String) data.get("name");
    int age = (Integer) data.get("age");
    String comment = (String) data.get("comment");
    if (name.compareTo(minName) < 0) {
        minName = name;
    }
    if (name.compareTo(maxName) > 0) {
        maxName = name;
    }
    if (age < minAge) {
        minAge = age;
    }
    if (age > maxAge) {
        maxAge = age;
    }

    if (comment.equals("hello")) {
        // expected
    }
    else if (comment.equals(longStr)) {
        longCommentCount++;
    }
    else {
        assertTrue(false);
    }
}
 
开发者ID:komamitsu,项目名称:fluency,代码行数:52,代码来源:BufferTestHelper.java


示例11: immutableValue

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
@Override
public ImmutableValue immutableValue()
{
    return new ImmutableArrayValueImpl(list.toArray(new Value[list.size()]));
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:6,代码来源:MsgpackGenerator.java


示例12: next

import org.msgpack.value.ImmutableValue; //导入依赖的package包/类
/**
 * @return the next {@code ImmutableValue}
 * @throws NoSuchElementException when no next value is found
 */
public ImmutableValue next() {
  return unpackedValues.remove();
}
 
开发者ID:okumin,项目名称:influent,代码行数:8,代码来源:MsgpackStreamUnpacker.java



注:本文中的org.msgpack.value.ImmutableValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JFXPopup类代码示例发布时间:2022-05-22
下一篇:
Java VKApiFriends类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap