void next(OrcStruct next)
            {
                if (recordReader.hasNext())
                {
                    nextRecord = (OrcStruct)recordReader.next(next);
                    // set the key
                    key.setValues(OrcRecordUpdater.getOriginalTransaction(nextRecord),
                                  OrcRecordUpdater.getBucket(nextRecord),
                                  OrcRecordUpdater.getRowId(nextRecord),
                                  OrcRecordUpdater.getCurrentTransaction(nextRecord),
                                  statementId);

                    // if this record is larger than maxKey, we need to stop
                    if (maxKey != null && key.compareRow(maxKey) > 0)
                    {
                        LOG.debug("key " + key + " > maxkey " + maxKey);
                        nextRecord = null;
                        recordReader.Dispose();
                    }
                }
                else
                {
                    nextRecord = null;
                    recordReader.Dispose();
                }
            }
示例#2
0
            /// <summary>
            /// find if we have been created earler if not create our node
            /// </summary>
            /// <param name="prefix"> the prefix node </param>
            /// <param name="zookeeper"> teh zookeeper client </param>
            /// <param name="dir"> the dir paretn </param>
            /// <exception cref="KeeperException"> </exception>
            private async Task findPrefixInChildren(string prefix, ZooKeeper zookeeper, string dir)
            {
                IList <string> names = (await zookeeper.getChildrenAsync(dir).ConfigureAwait(false)).Children;

                foreach (string name in names)
                {
                    if (name.StartsWith(prefix, StringComparison.Ordinal))
                    {
                        writeLock.Id = name;
                        if (LOG.isDebugEnabled())
                        {
                            LOG.debug("Found id created last time: " + writeLock.Id);
                        }
                        break;
                    }
                }
                if (writeLock.Id == null)
                {
                    writeLock.Id = await zookeeper.createAsync(dir + "/" + prefix, writeLock.data, writeLock.Acl, CreateMode.EPHEMERAL_SEQUENTIAL).ConfigureAwait(false);

                    if (LOG.isDebugEnabled())
                    {
                        LOG.debug("Created id: " + writeLock.Id);
                    }
                }
            }
示例#3
0
        static private void listarSeguidores(JSON json, string usuario, ArrayList cabeceras)
        {
            try {
                if (json.hayClave("pagination"))
                {
                    string siguiente = json["pagination"]["cursor"].ToString();
                    //Esperamos un tiempo para evitar que Twitch nos bloquee.
                    System.Threading.Thread.Sleep(100);
                    JSON json2 = new JSON();
                    json2.cargarJson("https://api.twitch.tv/helix/users/follows?to_id=" + usuario + "&after=" + siguiente, cabeceras);
                    listarSeguidores(json2, usuario, cabeceras);
                }
                else
                {
                    LOG.debug("Poner Seguidores");
                }
            } catch (Exception ex) {
                LOG.debug(ex.Message, "Poner Seguidores");
            }

            List <Dictionary <string, Entidad> > listado = (List <Dictionary <string, Entidad> >)json["data"].valor;

            for (int i = listado.Count - 1; i >= 0; i--)
            {
                Dictionary <string, Entidad> dato = listado[i];
                segui += (segui.Length > 0 ? ", " : "") + dato["from_name"].ToString().ToLower();
            }
        }
示例#4
0
 internal Loader(string @namespace, string effectivePath, params string[] subdirs)
 {
     this.@namespace    = @namespace;
     this.effectivePath = effectivePath;
     this.searchPath    = this.buildSearchPath(subdirs);
     LOG.debug("Assembly searchPath: {0}", this.searchPath);
     this.EnterCritical();
 }
 void next(OrcStruct next)
 {
     if (recordReader.hasNext())
     {
         long nextRowId = recordReader.getRowNumber();
         // have to do initialization here, because the super's constructor
         // calls next and thus we need to initialize before our constructor
         // runs
         if (next == null)
         {
             nextRecord = new OrcStruct(OrcRecordUpdater.FIELDS);
             IntWritable operation =
                 new IntWritable(OrcRecordUpdater.INSERT_OPERATION);
             nextRecord.setFieldValue(OrcRecordUpdater.OPERATION, operation);
             nextRecord.setFieldValue(OrcRecordUpdater.CURRENT_TRANSACTION,
                                      new LongWritable(0));
             nextRecord.setFieldValue(OrcRecordUpdater.ORIGINAL_TRANSACTION,
                                      new LongWritable(0));
             nextRecord.setFieldValue(OrcRecordUpdater.BUCKET,
                                      new IntWritable(bucket));
             nextRecord.setFieldValue(OrcRecordUpdater.ROW_ID,
                                      new LongWritable(nextRowId));
             nextRecord.setFieldValue(OrcRecordUpdater.ROW,
                                      recordReader.next(null));
         }
         else
         {
             nextRecord = next;
             ((IntWritable)next.getFieldValue(OrcRecordUpdater.OPERATION))
             .set(OrcRecordUpdater.INSERT_OPERATION);
             ((LongWritable)next.getFieldValue(OrcRecordUpdater.ORIGINAL_TRANSACTION))
             .set(0);
             ((IntWritable)next.getFieldValue(OrcRecordUpdater.BUCKET))
             .set(bucket);
             ((LongWritable)next.getFieldValue(OrcRecordUpdater.CURRENT_TRANSACTION))
             .set(0);
             ((LongWritable)next.getFieldValue(OrcRecordUpdater.ROW_ID))
             .set(0);
             nextRecord.setFieldValue(OrcRecordUpdater.ROW,
                                      recordReader.next(OrcRecordUpdater.getRow(next)));
         }
         key.setValues(0L, bucket, nextRowId, 0L, 0);
         if (maxKey != null && key.compareRow(maxKey) > 0)
         {
             if (LOG.isDebugEnabled())
             {
                 LOG.debug("key " + key + " > maxkey " + maxKey);
             }
             nextRecord = null;
             recordReader.close();
         }
     }
     else
     {
         nextRecord = null;
         recordReader.close();
     }
 }
示例#6
0
 public static void RemoveSearchPath(string path)
 {
     LOG.debug("RemoveSearchPath {0}", path);
     lock (CUSTOM_SEARCH_PATHS)
         if (CUSTOM_SEARCH_PATHS.Contains(path))
         {
             CUSTOM_SEARCH_PATHS.Remove(path);
         }
     LOG.debug("CUSTOM_SEARCH_PATHS : {0}", string.Join(":", CUSTOM_SEARCH_PATHS.ToArray()));
 }
示例#7
0
 public virtual void run()
 {
     try
     {
         outerInstance.processEngineConfiguration.CommandExecutorTxRequired.execute(new ControlledCommand(activeThread, new ActivityInstanceCancellationCmd(processInstanceId, activityInstanceId)));
     }
     catch (OptimisticLockingException e)
     {
         this.exception = e;
     }
     LOG.debug(Name + " ends");
 }
示例#8
0
 public override void run()
 {
     try
     {
         outerInstance.processEngineConfiguration.CommandExecutorTxRequired.execute(new ControlledCommand(activeThread, new CompleteTaskCmd(taskId, null)));
     }
     catch (ProcessEngineException e)
     {
         this.exception = e;
     }
     LOG.debug(Name + " ends.");
 }
示例#9
0
 public override void run()
 {
     try
     {
         outerInstance.processEngineConfiguration.CommandExecutorTxRequired.execute(new ControlledCommand <Void>(activeThread, createSuspendCommand()));
     }
     catch (OptimisticLockingException e)
     {
         this.exception = e;
     }
     LOG.debug(Name + " ends");
 }
示例#10
0
 public virtual void run()
 {
     try
     {
         outerInstance.runtimeService.signal(executionId);
     }
     catch (OptimisticLockingException e)
     {
         this.exception = e;
     }
     LOG.debug(Name + " ends");
 }
示例#11
0
 public override void run()
 {
     try
     {
         JobFailureCollector jobFailureCollector = new JobFailureCollector(jobId);
         ExecuteJobHelper.executeJob(jobId, outerInstance.processEngineConfiguration.CommandExecutorTxRequired, jobFailureCollector, new ControlledCommand <Void>(activeThread, new ExecuteJobsCmd(jobId, jobFailureCollector)));
     }
     catch (OptimisticLockingException e)
     {
         this.exception = e;
     }
     LOG.debug(Name + " ends");
 }
示例#12
0
 public virtual void run()
 {
     try
     {
         JobExecutor jobExecutor = outerInstance.processEngineConfiguration.JobExecutor;
         jobs = (AcquiredJobs)outerInstance.processEngineConfiguration.CommandExecutorTxRequired.execute(new ControlledCommand(activeThread, new AcquireJobsCmd(jobExecutor)));
     }
     catch (OptimisticLockingException e)
     {
         this.exception = e;
     }
     LOG.debug(Name + " ends");
 }
示例#13
0
 public override async Task process(WatchedEvent @event)
 {
     // lets either become the leader or watch the new/updated node
     LOG.debug("Watcher fired on path: " + @event.getPath() + " state: " + @event.getState() + " type " + @event.get_Type());
     try
     {
         await outerInstance.Lock().ConfigureAwait(false);
     }
     catch (Exception e)
     {
         LOG.warn("Failed to acquire lock: " + e, e);
     }
 }
示例#14
0
                protected virtual string TryPath(string path, params string[] subdirs)
                {
                    string t = SIO.Path.Combine(this.@namespace, path);

                    LOG.debug("Assembly TryPath: {0}", t);
                    LOG.force("Assembly TryPath: {0}", t);
                    string p = IO.Hierarchy.GAMEDATA.SolveFull(false, t, subdirs);

                    if (IO.Directory.Exists(p))
                    {
                        return(IO.Hierarchy.GAMEDATA.Solve(false, t, subdirs));
                    }

                    return(null);
                }
示例#15
0
 public virtual void run()
 {
     try
     {
         outerInstance.processEngineConfiguration.CommandExecutorTxRequired.execute(new ControlledCommand(activeThread, new SetTaskVariablesCmd(taskId, Collections.singletonMap(variableName, variableValue), false)));
     }
     catch (OptimisticLockingException e)
     {
         this.optimisticLockingException = e;
     }
     catch (Exception e)
     {
         this.exception = e;
     }
     LOG.debug(Name + " ends");
 }
示例#16
0
        static public int seguidores(string usuario)
        {
            int respuesta = 0;

            /*curl - H 'Client-ID: uo6dggojyb8d6soh92zknwmi5ej1q2' \
             * -X GET 'https://api.twitch.tv/helix/users/follows?to_id=23161357'
             */
            JSON      json      = new JSON();
            ArrayList cabeceras = new ArrayList();

            cabeceras.Add("Client-ID: " + Configuracion.parametro("id_cliente"));

            //Primero cogemos el total de usuarios que me siguen
            //misSeguidores = 0;
            Datos ultimoSeguidor = null;

            try {
                misSeguidores  = int.Parse(BD.consulta("select count(1) seguidores from seguidores where siguiendo=1")[0]["seguidores"].ToString());
                ultimoSeguidor = BD.consulta("select u.nombre \"nombre\", s.fecha fecha from seguidores s, usuarios u where u.id=s.idUsuario and s.siguiendo=1 order by fecha desc limit 1");
            } catch (Exception ex) {
                LOG.debug(ex.Message);
            }

            json.cargarJson("https://api.twitch.tv/helix/users/follows?to_id=" + usuario, cabeceras);
            respuesta = int.Parse(json["total"].ToString());
            if (respuesta != misSeguidores ||
                (ultimoSeguidor != null && ultimoSeguidor.Length > 0 && respuesta > 0 && ultimoSeguidor[0]["nombre"].ToString() != json["data"][0]["from_name"].ToString().ToLower()))
            {
                //Hay cambios entre mis seguidores.
                //Pueden suceder 2 casos que se haya ido alguien o que tengamos nuevos usuarios.
                //listarSeguidores(json, usuario, cabeceras);
                //JSON usuarioJSON = infoUsuarioId("173488279");
                //Para el caso de que perdamos seguidores haremos la taréa desantendida para evitar conflictos.
                if (respuesta == misSeguidores || respuesta < misSeguidores)
                {
                    quitarSeguidores(json, usuario, cabeceras);
                    //misSeguidores = int.Parse(BD.consulta("select count(1) seguidores from seguidores where siguiendo=1")[0]["seguidores"].ToString());
                }
                else
                {
                    ponerSeguidores(json, usuario, cabeceras, ultimoSeguidor);
                }
            }
            //seguidoresControlados = true;

            return(respuesta);
        }
示例#17
0
        static private List <string> quitarSeguidores(JSON json, string usuario, ArrayList cabeceras, int iteracion = 0)
        {
            List <string> nombres = null;

            try {
                if (json.hayClave("pagination"))
                {
                    string siguiente = json["pagination"]["cursor"].ToString();
                    //Esperamos un tiempo para evitar que Twitch nos bloquee.
                    System.Threading.Thread.Sleep(100);
                    JSON json2 = new JSON();
                    json2.cargarJson("https://api.twitch.tv/helix/users/follows?to_id=" + usuario + "&after=" + siguiente, cabeceras);
                    nombres = quitarSeguidores(json2, usuario, cabeceras, iteracion + 1);
                }
                else
                {
                    return(null);
                }
            } catch (Exception ex) {
                LOG.debug(ex.Message, "Poner Seguidores");
            }
            if (nombres == null)
            {
                nombres = new List <string>();
            }
            List <Dictionary <string, Entidad> > listado = (List <Dictionary <string, Entidad> >)json["data"].valor;

            for (int i = 0; i < listado.Count; i++)
            {
                nombres.Add(listado[i]["from_name"].ToString());
            }
            if (iteracion == 0)
            {
                string listaNombres = "";
                for (int i = 0; i < nombres.Count; i++)
                {
                    listaNombres += (i > 0 ? "," : "") + "'" + nombres[i] + "'";
                }
                try {
                    BD.ejecutar("update seguidores set siguiendo=0 where idUsuario in (select id from usuarios u where u.nombre not in(" + listaNombres + "))");
                } catch (Exception ex) {
                    LOG.debug(ex.Message, "Poner Seguidores update");
                }
            }
            return(nombres);
        }
示例#18
0
            public static void AddSearchPath(string path)
            {
                string fullpath = IO.Hierarchy.ROOT.SolveFull(false, path);

                if (!IO.Directory.Exists(fullpath))
                {
                    throw new SIO.FileNotFoundException(string.Format("The path {0} doesn't resolve to a valid DLL search path!", path));
                }

                LOG.debug("AddSearchPath {0}", path);
                lock (CUSTOM_SEARCH_PATHS)
                    if (!CUSTOM_SEARCH_PATHS.Contains(path))
                    {
                        CUSTOM_SEARCH_PATHS.Add(path);
                    }
                LOG.debug("CUSTOM_SEARCH_PATHS : {0}", string.Join(":", CUSTOM_SEARCH_PATHS.ToArray()));
            }
示例#19
0
        public static void Check <T>(System.Type versionClass, System.Type configurationClass)
        {
            string name        = SystemTools.Reflection.Version.Namespace(versionClass);
            string versionText = SystemTools.Reflection.Version.Text(versionClass);

            {
                int[] list = SystemTools.Reflection.Configuration.Unity(configurationClass);
                LOG.debug("*** desiredunityVersions {0}", list.Length);
                CheckForCompatibleUnity <T>(name, versionText, list);
            }
            {
                KSPe.Util.KSP.Version min = SystemTools.Reflection.Configuration.KSP.Min(configurationClass);
                KSPe.Util.KSP.Version max = SystemTools.Reflection.Configuration.KSP.Max(configurationClass);
                LOG.debug("*** desiredKSP Versions [{0}...{1}]", min, max);
                CheckForCompatibleKSP <T>(name, versionText, min, max);
            }
            {
                string[] list = SystemTools.Reflection.Configuration.Dependencies.Assemblies(configurationClass);
                LOG.debug("*** dependencyAssemblies {0}", list.Length);
                CheckForDependencyAssemblies <T>(name, versionText, list);
            }
            {
                string[] list = SystemTools.Reflection.Configuration.Dependencies.Types(configurationClass);
                LOG.debug("*** dependencyTypes {0}", list.Length);
                CheckForDependencyTypes <T>(name, versionText, list);
            }
            {
                string[] list = SystemTools.Reflection.Configuration.Conflicts.Assemblies(configurationClass);
                LOG.debug("*** conflictAssemblies {0}", list.Length);
                CheckForConflictAssemblies <T>(name, versionText, list);
            }
            {
                string[] list = SystemTools.Reflection.Configuration.Conflicts.Types(configurationClass);
                LOG.debug("*** conflictTypes {0}", list.Length);
                CheckForConflictTypes <T>(name, versionText, list);
            }
        }
示例#20
0
            /* slices a read only contiguous buffer of chunkLength */
            private ByteBuffer slice(int chunkLength)
            {
                int        len       = chunkLength;
                long       oldOffset = currentOffset;
                ByteBuffer slice;

                if (compressed.remaining() >= len)
                {
                    slice = compressed.slice();
                    // simple case
                    slice.limit(len);
                    currentOffset += len;
                    compressed.position(compressed.position() + len);
                    return(slice);
                }
                else if (currentRange >= (bytes.Count - 1))
                {
                    // nothing has been modified yet
                    throw new IOException("EOF in " + this + " while trying to read " +
                                          chunkLength + " bytes");
                }

                if (LOG.isDebugEnabled())
                {
                    LOG.debug(String.Format(
                                  "Crossing into next BufferChunk because compressed only has %d bytes (needs %d)",
                                  compressed.remaining(), len));
                }

                // we need to consolidate 2 or more buffers into 1
                // first copy out compressed buffers
                ByteBuffer copy = allocateBuffer(chunkLength, compressed.isDirect());

                currentOffset += compressed.remaining();
                len           -= compressed.remaining();
                copy.put(compressed);

                for (int i = currentRange; i < bytes.Count && len > 0; i++)
                {
                    ++currentRange;
                    if (LOG.isDebugEnabled())
                    {
                        LOG.debug(String.Format("Read slow-path, >1 cross block reads with {0}", this.ToString()));
                    }
                    DiskRange range = bytes[i];
                    compressed = range.getData().duplicate();
                    if (compressed.remaining() >= len)
                    {
                        slice = compressed.slice();
                        slice.limit(len);
                        copy.put(slice);
                        currentOffset += len;
                        compressed.position(compressed.position() + len);
                        return(copy);
                    }
                    currentOffset += compressed.remaining();
                    len           -= compressed.remaining();
                    copy.put(compressed);
                }

                // restore offsets for exception clarity
                seek(oldOffset);
                throw new IOException("EOF in " + this + " while trying to read " +
                                      chunkLength + " bytes");
            }
示例#21
0
            /// <summary>
            /// the command that is run and retried for actually
            /// obtaining the lock </summary>
            /// <returns> if the command was successful or not </returns>
            public async Task <bool> execute()
            {
                do
                {
                    if (writeLock.Id == null)
                    {
                        long   sessionId = writeLock.zookeeper.getSessionId();
                        string prefix    = "x-" + sessionId + "-";
                        // lets try look up the current ID if we failed
                        // in the middle of creating the znode
                        await findPrefixInChildren(prefix, writeLock.zookeeper, writeLock.dir).ConfigureAwait(false);

                        writeLock.idName = new ZNodeName(writeLock.Id);
                    }
                    if (writeLock.Id != null)
                    {
                        List <string> names = (await writeLock.zookeeper.getChildrenAsync(writeLock.dir).ConfigureAwait(false)).Children;
                        if (names.Count == 0)
                        {
                            LOG.warn("No children in: " + writeLock.dir + " when we've just " + "created one! Lets recreate it...");
                            // lets force the recreation of the id
                            writeLock.Id = null;
                        }
                        else
                        {
                            // lets sort them explicitly (though they do seem to come back in order ususally :)
                            SortedSet <ZNodeName> sortedNames = new SortedSet <ZNodeName>();
                            foreach (string name in names)
                            {
                                sortedNames.Add(new ZNodeName(writeLock.dir + "/" + name));
                            }
                            writeLock.ownerId = sortedNames.Min.Name;
                            SortedSet <ZNodeName> lessThanMe = new SortedSet <ZNodeName>();

                            foreach (ZNodeName name in sortedNames)
                            {
                                if (writeLock.idName.CompareTo(name) > 0)
                                {
                                    lessThanMe.Add(name);
                                }
                                else
                                {
                                    break;
                                }
                            }

                            if (lessThanMe.Count > 0)
                            {
                                ZNodeName lastChildName = lessThanMe.Max;
                                writeLock.lastChildId = lastChildName.Name;
                                if (LOG.isDebugEnabled())
                                {
                                    LOG.debug("watching less than me node: " + writeLock.lastChildId);
                                }
                                Stat stat = await writeLock.zookeeper.existsAsync(writeLock.lastChildId, new LockWatcher(writeLock)).ConfigureAwait(false);

                                if (stat != null)
                                {
                                    return(false);
                                }
                                LOG.warn("Could not find the" + " stats for less than me: " + lastChildName.Name);
                            }
                            else
                            {
                                if (writeLock.Owner)
                                {
                                    var tempCallback = writeLock.callback.Value;
                                    if (tempCallback != null)
                                    {
                                        await tempCallback.lockAcquired().ConfigureAwait(false);
                                    }
                                    return(true);
                                }
                            }
                        }
                    }
                } while (writeLock.Id == null);
                return(false);
            }
示例#22
0
 public override Task process(WatchedEvent @event)
 {
     LOG.debug("Watcher fired on path: " + @event.getPath() + " state: " + @event.getState() + " type " + @event.get_Type());
     latch.TrySetResult(true);
     return(CompletedTask);
 }