Beispiel #1
0
 public PublisherRemote(PuppetMaster pm, string name, string site, string addr)
 {
     _serviceName = name;
     _pm = pm;
     _site = site;
     c = (ICoordinator)Activator.GetObject(typeof(ICoordinator), addr);
 }
Beispiel #2
0
 public SubscriberRemote(PuppetMaster pm, string name, string site, string coordinatorURI)
 {
     _serviceName = name;
     _pm = pm;
     _site = site;
     c = (ICoordinator)Activator.GetObject(typeof(ICoordinator), coordinatorURI);
 }
Beispiel #3
0
        private void BtnStart_OnClick(object sender, RoutedEventArgs e)
        {
            var numberToBuy = Convert.ToInt32(cboMaxConsumables.SelectedItem);

            var minParse = int.TryParse(txtMinSell.Text, out var minPrice);
            var maxParse = int.TryParse(txtMaxSell.Text, out var maxPrice);

            //TODO: Fix this correctly
            minParse = true;
            maxParse = true;

            if (minParse && maxParse)
            {
                Logger.Log(LogType.Info, $"Program started. Searching for {numberToBuy} consumables.");

                var consumable = new Consumable
                {
                    NumberToPurchase = numberToBuy,
                    AutoSell         = AutoSellMode,
                    SellMin          = minPrice,
                    SellMax          = maxPrice
                };

                //TODO: This is broken and needs reworked.
                IPuppetMaster puppetMaster = new PuppetMaster(screenController, consumable, Logger);
                Task.Factory.StartNew(() => PuppetMaster_Go(puppetMaster));
            }
        }
        //public void Ack() { }

        public void ForcePublish(String topicName, String content)
        {
            PuppetMaster.WriteIntoLog("PubEvent " + Header.ProcessName + ", " + Header.ProcessName + ", " + topicName + ", " + Process.SeqNumber);
            if (Process.Frozen)
            {
                Process.Freeze(new Task(() => { Process.Publish(topicName, content); }));
                return;
            }
            Process.Publish(topicName, content);
        }
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            if (!Application.isPlaying)
            {
                GUI.color = EditorGUIUtility.isProSkin? pro: free;
                EditorGUILayout.BeginHorizontal();

                replace = (GameObject)EditorGUILayout.ObjectField("Replace Character Model", replace, typeof(GameObject), true);

                if (replace != null)
                {
                    if (GUILayout.Button("Replace"))
                    {
                        PropRoot   propRoot      = script.propRoot;
                        Vector3    localPosition = propRoot.transform.localPosition;
                        Quaternion localRotation = propRoot.transform.localRotation;
                        propRoot.transform.parent = null;

                        CharacterPuppetInspector.ReplacePuppetModel(script as CharacterThirdPerson, replace);

                        Animator     animator     = script.characterAnimation.GetComponent <Animator>();
                        PuppetMaster puppetMaster = script.transform.parent.GetComponentInChildren <PuppetMaster>();

                        propRoot.transform.parent        = animator.GetBoneTransform(HumanBodyBones.RightHand);
                        propRoot.transform.localPosition = localPosition;
                        propRoot.transform.localRotation = localRotation;
                        propRoot.puppetMaster            = puppetMaster;
                        propRoot.connectTo = GetRigidbody(puppetMaster, animator.GetBoneTransform(HumanBodyBones.RightLowerArm));

                        Debug.Log("You probably need to adjust the localPosition and localRotation of the Prop Root to match this character's hand.");

                        UserControlAI[] userControls = (UserControlAI[])GameObject.FindObjectsOfType <UserControlAI>();
                        foreach (UserControlAI ai in userControls)
                        {
                            if (ai.moveTarget == null)
                            {
                                ai.moveTarget = script.transform.parent.GetComponentInChildren <PuppetMaster>().muscles[0].joint.transform;
                            }
                        }
                    }
                }

                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;
            }

            DrawDefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(script);
            }
        }
Beispiel #6
0
        public void Setup()
        {
            TestContext.Progress.WriteLine("start setup");

            puppetMaster = PuppetMaster.getPuppetMaster();
            puppetMaster.addRoom("Lisboa", "4", "room1");
            puppetMaster.addRoom("Porto", "3", "room2");
            Thread.Sleep(3000);

            TestContext.Progress.WriteLine("setup done");
        }
        void Start()
        {
            Transform ragdoll = GameObject.Instantiate(ragdollPrefab, transform.position, transform.rotation) as Transform;

            ragdoll.name = instanceName;

            // This will duplicate the ragdoll character, remove the ragdoll components from the original and use it as the animated target.
            PuppetMaster.SetUp(ragdoll, characterControllerLayer, ragdollLayer);

            Debug.Log("A ragdoll was successfully converted to a Puppet.");
        }
        // Called by PropMuscle when this prop is dropped
        protected override void OnDrop(PuppetMaster puppetMaster, int propMuscleIndex)
        {
            // Called when the prop has been dropped.
            capsuleCollider.radius = defaultColliderRadius;

            // Toggle colliders back so the prop accurately collides with the scene while dropped.
            capsuleCollider.enabled = false;
            boxCollider.enabled     = true;

            StopAllCoroutines();
        }
 private Rigidbody GetRigidbody(PuppetMaster puppetMaster, Transform target)
 {
     foreach (Muscle m in puppetMaster.muscles)
     {
         if (m.target == target)
         {
             return(m.joint.GetComponent <Rigidbody>());
         }
     }
     return(null);
 }
Beispiel #10
0
        private void BtnStart_OnClick(object sender, RoutedEventArgs e)
        {
            CurrentSession.Reset();

            //TODO: This will need modified once we add multiple versions of a player
            var playerVersionId = SelectedPlayer.Versions.First().VersionId;
            var numberToBuy     = Convert.ToInt32(cboMaxPlayers.SelectedItem);

            CurrentSession.Current = new SessionDTO
            {
                AccessToken     = AccessToken,
                PlayerVersionId = playerVersionId,
                SearchNum       = numberToBuy,
                PurchasedNum    = 0,
                Captcha         = false
            };

            var canGetPlayer = Api.TryLockPlayerForSearch();

            if (canGetPlayer)
            {
                var price = cboMaxPrice.SelectedItem.ToString();

                int.TryParse(cboMinSell.SelectedValue?.ToString(), out var minPrice);
                int.TryParse(cboMaxSell.SelectedValue?.ToString(), out var maxPrice);

                var playerObject = new Core.Models.Player
                {
                    Name             = SelectedPlayer.Name,
                    NumberToPurchase = numberToBuy,
                    MaxPurchasePrice = price,
                    AutoSell         = AutoSellMode,
                    SellMin          = minPrice,
                    SellMax          = maxPrice,
                    PlayerVersionId  = playerVersionId
                };

                Logger.Log(LogType.Info, $"Program started. Searching for {numberToBuy} cards for Player: {SelectedPlayer.Name} at {price} price");

                IPuppetMaster puppetMaster = new PuppetMaster(screenController, playerObject, Logger, AutoRecover);
                puppetMaster.NavigateToTransferSearch();
                puppetMaster.SetSearchParameters();

                //TODO: Remove Debug Code
                Thread.Sleep(7000);

                Task.Factory.StartNew(() => PuppetMaster_Go(puppetMaster));
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Player is currently in use by another user");
            }
        }
Beispiel #11
0
 public BrokerRemote(PuppetMaster pm, string uri, string name, string site, string addr)
 {
     _uri = uri;
     _serviceName = name;
     _pm = pm;
     _site = site;
     _orderingPolicy = OrderingPolicy.fifo;
     _routingPolicy = RoutingPolicy.flooding;
     seq = 0;
     _coordinatorURI = addr;
     // c = (ICoordinator)Activator.GetObject(typeof(ICoordinator), addr);
 }
        private static ConfigurableJoint GetJoint(PuppetMaster puppetMaster, Animator animator, HumanBodyBones bone)
        {
            var boneTransform = animator.GetBoneTransform(bone);

            foreach (Muscle m in puppetMaster.muscles)
            {
                if (m.target == boneTransform)
                {
                    return(m.joint);
                }
            }
            return(null);
        }
        // Called by PropMuscle when this prop is picked up
        protected override void OnPickUp(PuppetMaster puppetMaster, int propMuscleIndex)
        {
            // Called when the prop has been picked up and connected to a PropRoot.
            capsuleCollider.radius = defaultColliderRadius;

            propMuscle.rigidbody.centerOfMass += COMOffset;
            mass = defaultMass;

            // Toggle colliders (capsule collisions are smoother and capsule radius bigger)
            capsuleCollider.enabled = true;
            boxCollider.enabled     = false;

            StopAllCoroutines();
        }
Beispiel #14
0
        private void bt_id_click(object sender, EventArgs e)
        {
            string pmId = this.tb_id.Text;

            if (pmId == null || pmId.Trim().Length == 0)
            {
                MessageBox.Show("No id given");
                return;
            }
            if (this.me == null)
            {
                this.me = new PuppetMaster(int.Parse(pmId));  //local instance
            }
        }
 public void DeliverEvent(Event @event)
 {
     PuppetMaster.WriteIntoLog(
         "SubEvent " +
         Header.ProcessName + ", " +
         @event.PublisherHeader.ProcessName + ", " +
         @event.TopicName + ", " +
         @event.SeqNumber);
     if (Process.Frozen)
     {
         Process.Freeze(new Task(() => { Process.ReceiveEvent(@event); }));
         return;
     }
     Process.ReceiveEvent(@event);
 }
 public void UnicastEvent(EventContainer eventContainer)
 {
     PuppetMaster.WriteIntoFullLog(
         "BroEvent " +
         Header.ProcessName + ", " +
         eventContainer.Event.PublisherHeader.ProcessName + ", " +
         eventContainer.Event.TopicName + ", " +
         eventContainer.Event.SeqNumber);
     if (Process.Frozen)
     {
         Process.Freeze(new Task(() => { Process.UnicastEvent(eventContainer); }));
         return;
     }
     Process.UnicastEvent(eventContainer);
 }
Beispiel #17
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("ENEMYHEAD"))
     {
         if (velocity.magnitude > 3)
         {
             Debug.Log("3을 넘었습니다");
             EnemyHealth        = other.gameObject.GetComponentInParent <EnemyHealth>();
             puppetMaster       = other.gameObject.GetComponentInParent <PuppetMaster>();
             puppetMaster.state = PuppetMaster.State.Dead;
             EnemyHealth.enemyHead.SetActive((false));
             EnemyHealth.enemyHeadRen.SetActive((false));
             EnemyHealth.EnemyHeadPart.SetActive(true);
             EnemyHealth.EnemyHeadPart.transform.parent = null;
         }
     }
 }
Beispiel #18
0
    public ActorParts(PuppetMaster puppet)
    {
        this.puppet   = puppet;
        bodyParts     = puppet.muscles;
        puppetRoot    = puppet.transform;
        animationRoot = puppet.targetAnimator.transform;

        initBodyParts();
        // 自动设置 propHandler
        propHandlers = animationRoot.GetComponentsInChildren <PropHandler>();
        foreach (var ph in propHandlers)
        {
            MuscleGroup mg = GetMuscleGroup(puppet.GetMuscleIndex(ph.transform.parent));
            mg.propHandler = ph;
            ph.Init(this, mg);
        }
        initPropHandlers();
    }
Beispiel #19
0
        void Awake()
        {
            puppetMaster = GetComponent <PuppetMaster>();

            // Assign the ragdoll layers.
            puppetMaster.gameObject.layer = ragdollLayer;

            foreach (Muscle m in puppetMaster.muscles)
            {
                if (m.joint == null)
                {
                }
                else
                {
                    m.joint.gameObject.layer = ragdollLayer;
                }
            }

            // Assign the character controller layer
            characterController.gameObject.layer = characterControllerLayer;

            // Ignore collisions between the ragdoll and the character controller
            Physics.IgnoreLayerCollision(characterControllerLayer, ragdollLayer);

            // Ignore collisions between character controllers
            Physics.IgnoreLayerCollision(characterControllerLayer, characterControllerLayer);

            // Ignore collisions between the puppet-damaging layers and the character controller layer
            int[] characterIgnoreIndexes = LayerMaskExtensions.MaskToNumbers(ignoreCollisionWithCharacterController);
            foreach (int index in characterIgnoreIndexes)
            {
                Physics.IgnoreLayerCollision(characterControllerLayer, index);
            }

            // Ignore collisions between the ragdoll and the ignoreCollisionWithRagdoll layers
            int[] ragdollIgnoreIndexes = LayerMaskExtensions.MaskToNumbers(ignoreCollisionWithRagdoll);
            foreach (int index in ragdollIgnoreIndexes)
            {
                Physics.IgnoreLayerCollision(ragdollLayer, index);
            }

            Destroy(this);
        }
Beispiel #20
0
        public void initialSetup()
        {
            SetUpChannel();

            puppetMaster = PuppetMaster.getPuppetMaster();
            puppetMaster.addRoom("Lisboa", "4", "room1");
            puppetMaster.addRoom("Porto", "3", "room2");

            //create servers
            server1 = puppetMaster.createServer("s1", "tcp://localhost:3001/server1", "1", "0", "0");
            server2 = puppetMaster.createServer("s2", "tcp://localhost:3002/server2", "1", "0", "0");
            server3 = puppetMaster.createServer("s3", "tcp://localhost:3003/server3", "1", "0", "0");
            Thread.Sleep(2000);

            //create clients
            client1 = puppetMaster.createClient("c1", "tcp://localhost:4001/client1", "tcp://localhost:3001/server1", "");
            client2 = puppetMaster.createClient("c2", "tcp://localhost:4002/client2", "tcp://localhost:3001/server1", "");
            client3 = puppetMaster.createClient("c3", "tcp://localhost:4003/client3", "tcp://localhost:3002/server2", "");
        }
Beispiel #21
0
    // -- IK Vars

    //-- CONSTRUCTOR -------------------------------------------------------------

    public Unit(string prefabName, string name, int unitID)
    {
        UnitParentObj  = Object.Instantiate(Resources.Load <GameObject>(prefabName));
        p_UnitAnimator = UnitParentObj.GetComponentInChildren <Animator>();
        UnitObj        = p_UnitAnimator.gameObject;
        p_BodyIK       = UnitObj.GetComponent <FullBodyBipedIK>();
        p_Puppet       = UnitParentObj.GetComponentInChildren <PuppetMaster>();
        Data           = new UnitData(name);
        UId            = UnitParentObj.GetComponent <UnitIdentifierMono>();
        UId.UnitID     = unitID;
        UId.UnitRef    = this;

        FaceCam = UId.FaceCam;
        FaceCam.targetTexture = UnitData.GetFaceCamTexture(unitID);

        p_SkinnedMeshes = UnitParentObj.GetComponentsInChildren <SkinnedMeshRenderer>();
        Material mat = UnitData.GetMaterial(unitID);

        for (int i = 0; i < p_SkinnedMeshes.Length; i++)
        {
            p_SkinnedMeshes[i].material = mat;
        }
    }
Beispiel #22
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Enemy"))
        {
            EnemyHealth enemyHealth = collision.gameObject.GetComponentInParent <EnemyHealth>();


            float hitVelocity = collision.relativeVelocity.magnitude;
            Debug.Log(hitVelocity + " Hitvelocity");
            Debug.Log(m_RigidBody.velocity.magnitude + " axe speed");
            Debug.Log(hitVelocity * 0.4f + " Hitvelocity halved");
            if (m_RigidBody.velocity.magnitude > hitVelocity * 0.4f)
            {
                if (hitVelocity > enemyHealth.ForceToRagdoll)
                {
                    PuppetMaster puppetMaster = collision.gameObject.GetComponentInParent <PuppetMaster>();
                    puppetMaster.state        = PuppetMaster.State.Dead;
                    puppetMaster.pinWeight    = 0;
                    puppetMaster.muscleWeight = 0;
                }
            }
        }
    }
Beispiel #23
0
 public BrokerRemote(BrokerForm form, PuppetMaster pm, string uri, string name, string site, string addr, string processName)
 {
     _form = form;
     _uri = uri;
     _serviceName = name;
     _site = site;
     _orderingPolicy = OrderingPolicy.fifo;
     _routingPolicy = RoutingPolicy.flooding;
     _coordinatorURI = addr;
     _processName = processName;
 }
Beispiel #24
0
 public FreezeJobTrackerCmd(PuppetMaster pm) : base(pm)
 {
 }
Beispiel #25
0
 public UnfreezeWorkerCmd(PuppetMaster pm) : base(pm)
 {
 }
Beispiel #26
0
 public SubmitJobCmd(PuppetMaster pm)
     : base(pm)
 {
 }
 public UnfreezeJobTrackerCmd(PuppetMaster pm)
     : base(pm)
 {
 }
Beispiel #28
0
        public static void ReplacePuppetModel(CharacterThirdPerson script, GameObject replace)
        {
            // Drag your Humanoid character to the scene, parent it to the "Animation Controller" just where the Pilot is
            GameObject find          = GameObject.Find(replace.name);
            bool       isSceneObject = find != null && find == replace;

            GameObject instance = isSceneObject? replace: (GameObject)GameObject.Instantiate(replace, script.transform.position, script.transform.rotation);

            instance.transform.parent   = script.characterAnimation.transform;
            instance.name               = replace.name;
            instance.transform.position = script.transform.position;
            instance.transform.rotation = script.transform.rotation;

            Animator animator   = instance.GetComponentInChildren <Animator>();
            bool     isAnimator = animator != null;

            if (!isAnimator || !animator.isHuman)
            {
                Debug.LogWarning("The demo character controller requires a Humanoid character.");
                return;
            }

            SkinnedMeshRenderer[] skinnedMeshRenders = instance.GetComponentsInChildren <SkinnedMeshRenderer>();
            foreach (SkinnedMeshRenderer s in skinnedMeshRenders)
            {
                s.updateWhenOffscreen = true;
            }

            // Unparent "Character Controller" from the "ThirdPersonPuppet"
            Transform              oldRoot          = script.transform.parent;
            PuppetMaster           oldPM            = script.transform.parent.GetComponentInChildren <PuppetMaster>();
            RigidbodyInterpolation oldInterpolation = oldPM.muscles[0].joint.GetComponent <Rigidbody>().interpolation;

            BehaviourBase[]  behaviours       = script.transform.parent.GetComponentsInChildren <BehaviourBase>();
            Camera           camera           = script.transform.parent.GetComponentInChildren <Camera>();
            CameraController cameraController = null;

            if (camera != null)
            {
                cameraController = camera.gameObject.GetComponent <CameraController>();
            }
            LayerSetup layerSetup = oldPM.GetComponent <LayerSetup>();

            script.transform.parent = null;

            // Delete the "Pilot"
            DestroyImmediate(script.characterAnimation.transform.GetChild(0).gameObject);

            // Replace the Avatar in the Animator component of the "Animation Controller" gameobject.
            Animator characterAnimator = script.characterAnimation.GetComponent <Animator>();

            characterAnimator.avatar = animator.avatar;

            // Add BipedRagdollCreator to the "Animation Controller", use it to create a ragdoll, delete the component when done
            Joint joint          = instance.GetComponentInChildren <Joint>();
            bool  isRagdoll      = joint != null;
            bool  isConfigurable = isRagdoll && joint is ConfigurableJoint;

            if (isRagdoll && !isConfigurable)
            {
                JointConverter.ToConfigurable(instance);
            }

            if (!isRagdoll)
            {
                BipedRagdollReferences      r       = BipedRagdollReferences.FromAvatar(animator);
                BipedRagdollCreator.Options options = BipedRagdollCreator.AutodetectOptions(r);

                // Edit options here if you need to

                BipedRagdollCreator.Create(r, options);
            }

            // Delete the Animator from your character root (not the one on "Animation Controller")
            DestroyImmediate(animator);

            // Add PuppetMaster to the "Character Controller", click on Set Up PuppetMaster.
            int cLayer = layerSetup != null? layerSetup.characterControllerLayer: script.gameObject.layer;
            int rLayer = layerSetup != null? layerSetup.ragdollLayer: oldPM.muscles[0].joint.gameObject.layer;

            PuppetMaster newPuppetMaster = PuppetMaster.SetUp(script.transform, cLayer, rLayer);

            foreach (Muscle m in newPuppetMaster.muscles)
            {
                m.joint.GetComponent <Rigidbody>().interpolation = oldInterpolation;
            }

            // Move the "Puppet" and "Fall" behaviours from the old rig to the new one (parent them to the "Behaviours").
            Transform behaviourRoot    = newPuppetMaster.transform.parent.FindChild("Behaviours");
            Transform oldBehaviourRoot = behaviours.Length > 0? behaviours[0].transform.parent: FindChildNameContaining(oldRoot, "Behaviours");

            foreach (BehaviourBase behaviour in behaviours)
            {
                behaviour.transform.parent = behaviourRoot;
            }
            if (oldBehaviourRoot != null)
            {
                DestroyImmediate(oldBehaviourRoot.gameObject);
            }

            // 9. Move the "Character Camera" to the new rig, replace the "Target" of the CharacterController component
            if (camera != null)
            {
                camera.transform.parent = newPuppetMaster.transform.parent;
            }
            if (cameraController != null)
            {
                cameraController.target = newPuppetMaster.muscles[0].joint.transform;
            }

            // THIS IS NOT REQUIRED SINCE 0.3 Use the RagdollEditor (add it to the PuppetMaster) to multiply the mass of the ragdoll by 10

            // 10. Copy the LayerSetup component from the old PuppetMaster to the new one if you have not set up the layers in the Layer Collision Matrix.
            if (layerSetup != null)
            {
                LayerSetup newLayerSetup = newPuppetMaster.gameObject.AddComponent <LayerSetup>();
                if (newLayerSetup != null)
                {
                    newLayerSetup.characterController      = layerSetup.characterController;
                    newLayerSetup.characterControllerLayer = layerSetup.characterControllerLayer;
                    newLayerSetup.ragdollLayer             = layerSetup.ragdollLayer;
                    newLayerSetup.ignoreCollisionWithCharacterController = layerSetup.ignoreCollisionWithCharacterController;
                }
            }

            //	11. Make sure the new PuppetMaster settings match with the old one, delete the old rig
            newPuppetMaster.state                       = oldPM.state;
            newPuppetMaster.stateSettings               = oldPM.stateSettings;
            newPuppetMaster.mode                        = oldPM.mode;
            newPuppetMaster.blendTime                   = oldPM.blendTime;
            newPuppetMaster.fixTargetTransforms         = oldPM.fixTargetTransforms;
            newPuppetMaster.solverIterationCount        = oldPM.solverIterationCount;
            newPuppetMaster.visualizeTargetPose         = oldPM.visualizeTargetPose;
            newPuppetMaster.mappingWeight               = oldPM.mappingWeight;
            newPuppetMaster.pinWeight                   = oldPM.pinWeight;
            newPuppetMaster.muscleWeight                = oldPM.muscleWeight;
            newPuppetMaster.muscleSpring                = oldPM.muscleSpring;
            newPuppetMaster.muscleDamper                = oldPM.muscleDamper;
            newPuppetMaster.pinPow                      = oldPM.pinPow;
            newPuppetMaster.pinDistanceFalloff          = oldPM.pinDistanceFalloff;
            newPuppetMaster.updateJointAnchors          = oldPM.updateJointAnchors;
            newPuppetMaster.supportTranslationAnimation = oldPM.supportTranslationAnimation;
            newPuppetMaster.angularLimits               = oldPM.angularLimits;
            newPuppetMaster.internalCollisions          = oldPM.internalCollisions;

            // 12 Parent this CharacterPuppet to the new puppet root
            script.transform.parent = newPuppetMaster.transform.parent;

            // 13. Delete the old root
            script.transform.parent.name = oldRoot.name;

            for (int i = 0; i < oldRoot.childCount; i++)
            {
                var child = oldRoot.GetChild(i);
                if (child != oldPM.transform && child != behaviourRoot)
                {
                    child.parent = script.transform.parent;
                }
            }
            DestroyImmediate(oldRoot.gameObject);
        }
 public StatusIndividualCmd(PuppetMaster pm)
     : base(pm)
 {
 }
Beispiel #30
0
        public static void Main(string[] args)
        {
            // Check args validity
            if (args.Length != 3)
            {
                Console.WriteLine("[Operator] Usage: OperatorExecutable <serialized_operator> <replicaID>!");
                Console.WriteLine("[Operator] Received: ");
                foreach (string s in args)
                {
                    Console.WriteLine(s);
                }
                exiting(5);
                return;
            }

            // Parse operator
            string   serializedOperator = args[0];
            Operator operatorData;

            try {
                operatorData = Operator.deserialize(serializedOperator);
            } catch (Exception e) {
                Console.WriteLine("[Operator] Couldn't deserialize the operator. Cause: {0}", e.Message);
                Console.WriteLine("[Operator] Received: {0}", serializedOperator);
                exiting(10);
                return;
            }

            // Parse replicaId
            int replicaID;

            try {
                replicaID = int.Parse(args[1]);
                if (replicaID >= operatorData.replicaURLs.Count)
                {
                    throw new Exception();
                }
            } catch (Exception) {
                Console.WriteLine("[REPLICA] ReplicaID was not a valid or out of range integer!");
                exiting(5);
                return;
            }
            myURL = operatorData.replicaURLs[replicaID];

            Console.WriteLine("------------------------------------------------------------------");
            Console.WriteLine("[REPLICA] Operator: {0}({1})! URL: {2}", operatorData.id, replicaID, myURL);
            Console.WriteLine("------------------------------------------------------------------");


            // initializeOperatorSpec
            var kernel = initializeOperatorSpec(operatorData);
            var downstreamOperators = SetUpDownstream(operatorData);

            // Connect to the puppet master
            string puppetMasterLoggerUrl = args[2];

            try {
                PuppetMaster = (IPuppetMaster)Activator.GetObject(typeof(IPuppetMaster), puppetMasterLoggerUrl);
                Console.WriteLine("[Replica] Created proxy for puppetMaster at {0}", puppetMasterLoggerUrl);

                PuppetMaster.log("Replica " + operatorData.id + " of operator " + myURL + " launched.");
            } catch (Exception e) {
                Console.WriteLine("[Operator] Unable to talk to the puppetMaster at: {0}. Cause: {1}", puppetMasterLoggerUrl, e.Message);
            }

            //System.Diagnostics.Debugger.Launch();
            var localRoutingStrategy = RoutingPolicyToStrategy(operatorData.routingPolicy, operatorData.HashingField);
            var localReplica         = new LocalReplica(operatorData.id, replicaID, null);
            var tupleIdGenerator     = new TupleIdGenerator(operatorData.id, replicaID);
            var monitoringProcess    = new MonitoringProcess();
            var group          = new GroupManager(SetUpGroup(operatorData, replicaID, localReplica), localReplica, monitoringProcess, localRoutingStrategy);
            var tupleProcessor = new TupleProcessor(kernel, downstreamOperators, tupleIdGenerator, group);

            thisReplica = new ReplicaServices(tupleProcessor, group, monitoringProcess, operatorData, operatorData.id, replicaID);
            localReplica.SetProxy(thisReplica);

            // Publish the service
            string replicaURL  = operatorData.replicaURLs[replicaID];
            string serviceName = getNameFromURL(replicaURL);

            try {
                int servicePort = getPortFromURL(replicaURL);

                TcpChannel channel = new TcpChannel(servicePort);
                // @SEE: I think because the PCS has already registered a channel and this processe is a child of it we can´t register again?
                //ChannelServices.RegisterChannel(channel, false); // @SEE: should be true??

                Type serviceType = typeof(ReplicaServices);
                RemotingServices.Marshal(thisReplica, serviceName, serviceType);

                System.Console.WriteLine("Started Operator with name {0} at port {1}.", serviceName, servicePort);
            }
            catch (Exception e) {
                Console.WriteLine("[Operator] Unable to publish {0}. Cause: {1}", replicaURL, e.Message);
                exiting(20);
                return;
            }

            // See if we need to read from a file
            foreach (string fileName in operatorData.inputFiles)
            {
                readTuplesFromFile(INPUT_FOLDER_PATH + fileName, tupleIdGenerator);
            }

            Console.ReadLine();
        }
Beispiel #31
0
 public SleepCmd(PuppetMaster pm)
     : base(pm)
 {
 }
Beispiel #32
0
 public StatusCmd(PuppetMaster pm) : base(pm)
 {
 }
Beispiel #33
0
 public HumanoidParts(PuppetMaster puppet) : base(puppet)
 {
 }
Beispiel #34
0
 public SubmitJobCmd(PuppetMaster pm) : base(pm)
 {
 }
 public EnableJobTrackerCmd(PuppetMaster pm) : base(pm) { }
Beispiel #36
0
 public CreateWorkerCmd(PuppetMaster pm) : base(pm)
 {
 }
Beispiel #37
0
 public EnableJobTrackerCmd(PuppetMaster pm) : base(pm)
 {
 }
Beispiel #38
0
 public DelayWorkerCmd(PuppetMaster pm) : base(pm)
 {
 }
Beispiel #39
0
 public Command(PuppetMaster pm)
 {
     this.puppetMaster = pm;
 }
Beispiel #40
0
 public DelayWorkerCmd(PuppetMaster pm)
     : base(pm)
 {
 }
 public UnfreezeWorkerCmd(PuppetMaster pm)
     : base(pm)
 {
 }
 public CreateWorkerCmd(PuppetMaster pm)
     : base(pm)
 {
 }
Beispiel #43
0
 public StatusCmd(PuppetMaster pm)
     : base(pm)
 {
 }
Beispiel #44
0
 public WaitCmd(PuppetMaster pm) : base(pm) { }
Beispiel #45
0
 public SleepCmd(PuppetMaster pm) : base(pm)
 {
 }