/**
   * @param ctx {@code GridKernalContext} instance which provides deployment manager
   * @param o Object for which deployment should be obtained.
   * @return Deployment object for given instance,
   * @throws IgniteCheckedException If node cannot create deployment for given object.
   */
  private static GridAffinityMessage affinityMessage(GridKernalContext ctx, Object o)
      throws IgniteCheckedException {
    Class cls = o.getClass();

    GridDeployment dep = ctx.deploy().deploy(cls, cls.getClassLoader());

    if (dep == null)
      throw new IgniteDeploymentCheckedException(
          "Failed to deploy affinity object with class: " + cls.getName());

    return new GridAffinityMessage(
        U.marshal(ctx, o),
        cls.getName(),
        dep.classLoaderId(),
        dep.deployMode(),
        dep.userVersion(),
        dep.participants());
  }