Author Archives: Robins

MAFIA: 1- OpenFlow statistics (Counters, Timestamps)(mafia-sdn/p4demos/demos/1-openflow/1.1-statistics/p4src/of.p4)

1.1 – The core problem solved by OpenFlow statistics (Counters, Timestamps) : how to count the duration of a flow

  1. How to implement an operation to be executed only once when the data packet first appears, and never again: set the default operation to update the duration. The first time the timestamp is read from the register to the metadata, it is 0, set a flow table, and the matching key of the corresponding field in the metadata is 0, and then the action executed is to record the current timestamp and modify the metadata of this field Data is the current timestamp. From then on, the corresponding field of this metadata is no longer 0. This operation also achieves the purpose of executing only the first time the data packet appears.
  2. How to record the timestamp of the last packet of a flow. The timestamp of each data packet of the flow is updated when it arrives, and the last saved timestamp must be the timestamp of the last data packet.

mafia-sdn/p4demos/demos/1-openflow/1.1-statistics/commands.txt

table_set_default counter_table _no_op
table_add counter_table do_count 10.0.0.1 10.0.0.2 => 0
table_add counter_table do_count 10.0.0.1 10.0.0.3 => 1
table_add counter_table do_count 10.0.0.2 10.0.0.1 => 2
table_add counter_table do_count 10.0.0.2 10.0.0.3 => 3
table_add counter_table do_count 10.0.0.3 10.0.0.1 => 4
table_add counter_table do_count 10.0.0.3 10.0.0.2 => 5
table_set_default duration_table update_duration	(2. Each time after that, the default update duration operation is performed)
table_add duration_table update_start_ts 0 =>	(1. Only the first time you can match this flow table, then perform the operation of storing the initial time)

mafia-sdn/p4demos/demos/1-openflow/1.1-statistics/p4src/includes/counters.p4

#define TABLE_INDEX_WIDTH 3 // Number of bits to index the duration register
#define N_FLOWS_ENTRIES 8 // Number of entries for flow (2^3)

header_type my_metadata_t {
    fields {
        nhop_ipv4: 32;
        pkt_ts: 48; // Loaded with intrinsic metadata: ingress_global_timestamp
        tmp_ts: 48; // Temporary variable to load start_ts    
        pkt_count: 32;
        byte_count: 32;
        register_index: TABLE_INDEX_WIDTH;
    }
}
metadata my_metadata_t my_metadata;



register my_byte_counter {
    width: 32;
    instance_count: N_FLOWS_ENTRIES;
}

register my_packet_counter {
    width: 32;
    instance_count: N_FLOWS_ENTRIES;
}

register start_ts{
    width: 48;
    instance_count: N_FLOWS_ENTRIES;
}
register last_ts{
    width: 48;
    instance_count: N_FLOWS_ENTRIES;
}
register flow_duration{ // Optional register...Duration can be derived from the two timestamp
    width: 48;
    static: duration_table;
    instance_count: N_FLOWS_ENTRIES;
}

mafia-sdn/p4demos/demos/1-openflow/1.1-statistics/p4src/of.p4

#include "includes/headers.p4"
#include "includes/parser.p4"
#include "includes/counters.p4"

action _no_op() {
    drop();
}
action _drop() {
    drop();
}

// Action and table to count packets and bytes. Also load the start_ts to be matched against next table.
action do_count(entry_index) {
    modify_field(my_metadata.register_index, entry_index); // Save the register index
    modify_field(my_metadata.pkt_ts, intrinsic_metadata.ingress_global_timestamp); // Load packet timestamp in custom metadata

    // Update packet counter (read + add + write)Update Package Counter
    register_read(my_metadata.pkt_count, my_packet_counter, my_metadata.register_index);
    add_to_field(my_metadata.pkt_count, 1);
    register_write(my_packet_counter, my_metadata.register_index, my_metadata.pkt_count);

    // Update byte counter (read + add + write)Update byte counter
    register_read(my_metadata.byte_count, my_byte_counter, my_metadata.register_index);
    add_to_field(my_metadata.byte_count, standard_metadata.packet_length);
    register_write(my_byte_counter, my_metadata.register_index, my_metadata.byte_count);
    
    // Cant do the following if register start_ts is associated to another table (eg: duration_table)...
    // Semantic error: "static counter start_ts assigned to table duration_table cannot be referenced in an action called by table counter_table"Read the value in the register into my_metadata.tmp_ts, the first read is 0, so it can match the upstream table, all subsequent reads are not 0. So only the default operation is performed.
    register_read(my_metadata.tmp_ts, start_ts, entry_index); // Read the start ts for the flow

}
table counter_table {
    reads {
        ipv4.srcAddr : exact;
        ipv4.dstAddr : exact;
    }
    actions {
        do_count;
        _no_op;
    }
    size : 1024;
}

// Action and table to update the start and end timestamp of the flow.
// Optionally, the duration can as well be stored in a register.

// Action is called only when start_ts=0 (value loaded in my_metadata from my_count action)
action update_start_ts(){
    register_write(start_ts, my_metadata.register_index, my_metadata.pkt_ts); // Update start_ts
    update_duration();
}
// Default action: only update the timestamp for the last matched packet and the duration default operation to get the timestamp and current duration of the last packet.
action update_duration(){
    register_write(last_ts, my_metadata.register_index, my_metadata.pkt_ts); // Update ts of the last seen packet  
    subtract_from_field(my_metadata.pkt_ts, my_metadata.tmp_ts); // Calculate duration
    register_write(flow_duration, my_metadata.register_index, my_metadata.pkt_ts); // Optional: save duration in stateful register
}
table duration_table{
    reads{
        my_metadata.tmp_ts : exact;
    }
    actions{
        update_start_ts;
        update_duration;
    }
}

control ingress { 
  apply(counter_table);
  apply(duration_table);
}


table table_drop {
    actions { 
        _drop;
    }
}
control egress {
    apply(table_drop);
}

LDSC: Could not open Corces_ATAC_1000Gv3_ldscores/Corces_ATAC.1.1.l2.ldscore[./gz/bz2]

The error that occurs when running the following script IOError: Could not open Corces_ATAC_1000Gv3_ldscores/Corces_ATAC.1.1.l2.ldscore[./gz/bz2]:

ldsc.py \
    --h2-cts UKBB_BMI.sumstats.gz \
    --ref-ld-chr 1000G_EUR_Phase3_baseline/baseline. \
    --out BMI_Corces_ATAC \
    --ref-ld-chr-cts /ldsc/data/Corces_ATAC.ldcts \
    --w-ld-chr weights_hm3_no_hla/weights.

Solution, specify the absolute path of the Corces_ATAC_1000Gv3_ldscores folder, for example, the Corces_ATAC_1000Gv3_ldscores folder is stored in /ldsc/data, then it can be modified as follows:

cd /ldsc/data
ldsc.py \
    --h2-cts UKBB_BMI.sumstats.gz \
    --ref-ld-chr 1000G_EUR_Phase3_baseline/baseline. \
    --out BMI_Corces_ATAC \
    --ref-ld-chr-cts /ldsc/data/Corces_ATAC.ldcts \
    --w-ld-chr weights_hm3_no_hla/weights.

It can be understood that this is a bug of ldsc. ldsc needs to call Corces_ATAC_1000Gv3_ldscores/Corces_ATAC.1.1.l2.ldscoredata internally, but there is no such parameter in the official script to specify Corces_ATAC_1000Gv3_ldscores/Corces_ATAC.1.1.l2.ldscorethe data, so the data cannot be found when running.
Therefore, you only need to add cd /ldsc/datasuch a parameter before running.

Gradle Package Project Lombok Not Working: No serializer found for class com.qbb.User and no properties discovered to create BeanSerializer……

Full error:

03-Dec-2022 16:57:22.941 涓ラ噸 [http-nio-8080-exec-5] org.apache.catalina.core.StandardWrapperValve.invoke 鍦ㄨ矾寰勪负/ssm鐨勪笂涓嬫枃涓紝Servlet[DispatcherServlet]鐨凷ervlet.service锛堬級寮曞彂浜嗗叿鏈夋牴鏈師鍥犵殑寮傚父Request processing failed; nested exception is org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class com.qbb.User]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.qbb.User and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0])
	com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.qbb.User and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0])
		at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
		at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1276)
		at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:400)
		at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:71)
		at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:33)
		at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:145)
		at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:107)
		at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:25)
		at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
		at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:400)
		at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1510)
		at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:1006)
		at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:456)
		at org.springframework.http.converter.AbstractGenericHttpMessageConverter.write(AbstractGenericHttpMessageConverter.java:104)
		at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:290)
		at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:183)
		at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:78)
		at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:135)
		at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
		at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
		at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
		at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1070)
		at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
		at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
		at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
		at javax.servlet.http.HttpServlet.service(HttpServlet.java:670)
		at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
		at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
		at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
		at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:94)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
		at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
		at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
		at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
		at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
		at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
		at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
		at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
		at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
		at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
		at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
		at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
		at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891)
		at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784)
		at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
		at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
		at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
		at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
		at java.base/java.lang.Thread.run(Thread.java:833)

Solution 1:

Add getter and settermethod to the entity class that reported the error

think:

Because I use Lombok, and add the @Data annotation to the entity class, the get/set method also exists , so why doesn’t it take effect? This can’t help arousing my interest, I will build the project first, and check the classes directory

Solution 2:

Add the following codes in build.gradle

project("gradle-ssm-domain") {
    dependencies {
       ......
        // lombok does not take effect after solving Gradle packaging
        api 'org.projectlombok:lombok:1.18.24'
        annotationProcessor 'org.projectlombok:lombok:1.18.24'
    }
}

[Solved] PCH Warning: header stop not at file scope

Produces warnings when importing custom header files:PCH Warning: header stop not at file scope

The editor is VSCode, the compiler is g++11IntelliSense, and the code checker (that is, the one that reports the error) is IntelliSense.

The specific reason is: the syntax of c++17 is used in the code, which does not match the configuration of IntelliSense, and IntelliSense cannot recognize the syntax of the header file during precompilation.

According to the error message, find the relevant configuration of IntelliSense, because there are multiple c++ compilers on the computer, but there is no corresponding configuration when using IntelliSense. As can be seen the compiler used is clangnot actually used g++11.

clang

Modify the compiler configuration and add parameters -std=c++17to make the precompilation of IntelliSense work normally, indicating that the syntax of c++17 is used.

g++

Or do not add parameters -std=c++17, there is a configuration below that can modify the c++ standard used, and it can also work normally if it is changed to c++17.

c++17

pymysql Error: File “/usr/local/lib/python2.7/site-packages/PyMySQL-1.0.2-py2.7.egg/pymysql/connections.py”, line 167 SyntaxError: invalid syntax

raceback (most recent call last):
  File "log2user-real.py", line 49, in <module>
    db = create_engine("mysql+pymysql://root:{m_pass}@10.157.2.25:8306/log_user?charset=utf8".format(m_pass=m_pass))
  File "<string>", line 2, in create_engine
  File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/deprecations.py", line 309, in warned
    return fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/create.py", line 548, in create_engine
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/usr/local/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/pymysql.py", line 68, in dbapi
    return __import__("pymysql")
  File "build/bdist.linux-x86_64/egg/pymysql/__init__.py", line 59, in <module>
  File "/usr/local/lib/python2.7/site-packages/PyMySQL-1.0.2-py2.7.egg/pymysql/connections.py", line 167
    *,
     ^
SyntaxError: invalid syntax
Reason: The latest version of PyMySQL does not support Python 2.7

Solution: Specify the PyMySQL version as 0.10.1, and write in the requirements.txt file:PyMySQL==0.10.1

pip install pymysql==0.10.1

try-with-resource automatically closes the resources of the AutoClosable interface

Common classes that implement the AutoCloseable interface are:

BufferedInputStream, BufferedOutputStream

BufferedReader, BufferedWriter

FileInputStream, FileOutputStream

FileReader, FileWriter

InputStream, OutputStream

PrintWriter, PrintStream

Reader, Writer

Scanner, SSLServerSocker, SSLSocket, etc. etc.

for example

try–catch-finally implementation
Scanner scanner = null;
try {
    scanner = new Scanner(new File("test.txt"));
    while (scanner.hasNext()) {
        System.out.println(scanner.nextLine());
    }
} catch (FileNotFoundException e) {
    e.printStackTrace();
} finally {
    if (scanner != null) {
        scanner.close();
    }
}
try-with-resources implementation
try (Scanner scanner = new Scanner(new File("testRead.txt")); 
PrintWriter writer = new PrintWriter(new File("testWrite.txt"))) {

    while (scanner.hasNext()) {
        writer.print(scanner.nextLine());
    }

}catch (FileNotFoundException e) {
    e.printStackTrace();
}

Unity: How to Implement Timer

The first step is to implement the UpdateRegister function, inherited from MonoBehavior, and use Unity’s own Update method. Functionality provided to external registration and deregistration

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

namespace JunFramework
{
    public enum UpdateMode
    {
        Update,
        FixedUpdate,
        LateUpdate
    }

    public enum TimeMode
    {
        Scaled,
        UnScaled
    }
    public class UpdateRegister : MonoBehaviour
    {
        /// <summary>
        /// update
        /// </summary>
        private static Dictionary<int, Action> update = new Dictionary<int, Action>();

        /// <summary>
        /// fixedupfate
        /// </summary>
        private static Dictionary<int, Action> fixedupdate = new Dictionary<int, Action>();

        /// <summary>
        /// lateupdate
        /// </summary>
        private static Dictionary<int, Action> lateupdate = new Dictionary<int,Action>(); 

        ///  <summary> 
        /// Globally unique update subscript
         ///  </summary> 
        private  static  int updateIndex = 0 ; 
      
        ///  <summary> 
        /// Whether to initialize
         ///  </summary> 
        private  static  bool isInit = false ; 

        ///  <summary> 
        /// has been initialized
         ///  </summary> 
        public  static  bool IsInit 
        { 
            get => isInit; 
        } 

        ///  <summary> 
        /// register
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="handler"></param>
        /// <returns></returns>
        public static int Register(UpdateMode mode, Action handler)
        {
            ++updateIndex;
            switch (mode)
            {
                case UpdateMode.Update:
                    update.Add(updateIndex, handler);
                    break;
                case UpdateMode.FixedUpdate:
                    fixedupdate.Add(updateIndex, handler);
                    break;
                case UpdateMode.LateUpdate:
                    lateupdate.Add(updateIndex, handler);
                    break;
            }
            return updateIndex;
        }

        /// <summary>
        /// Unregister according to updateindex
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="index"></param>
        public static void Cancle(UpdateMode mode, int index)
        {
            switch (mode)
            {
                case UpdateMode.Update:
                    update.Remove(index);
                    break;
                case UpdateMode.FixedUpdate:
                    fixedupdate.Remove(index);
                    break;
                case UpdateMode.LateUpdate:
                    lateupdate.Remove(index);
                    break;
            }
        }

        private void Awake()
        {
            isInit = true;
        }

        private void Update()
        {
            using (var e = update.GetEnumerator())
            {
                if (e.MoveNext())
                {
                    e.Current.Value?.Invoke();
                }
            }
        }

        private void FixedUpdate()
        {
            using (var e = fixedupdate.GetEnumerator())
            {
                if (e.MoveNext())
                {
                    e.Current.Value?.Invoke();
                }
            }
        }

        private void LateUpdate()
        {
            using (var e = lateupdate.GetEnumerator())
            {
                if (e.MoveNext())
                {
                    e.Current.Value?.Invoke();
                }
            }
        }
    }
}

The second step is to implement the Timer object, store the information passed in by the caller, and get the Timer status (is it completed? Is it working? Current progress?). Callable start, end, pause, resume, reset, finish functions

using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using System; 

namespace JunFramework.Timer 
{ 
    public  class Timer 
    { 
        #region timer setting /// <summary> /// Timer is automatically released
         /// </summary > public static bool IsAutoRelease = true ; /// <summary> /// Timer update mode
         /// </summary> public static UpdateMode TimerUpdateMode =

         
         
          

         
         
         UpdateMode.FixedUpdate; 

        ///  <summary> 
        /// Whether the Timer time is affected by Unity scaling
         ///  </summary> 
        public  static TimeMode TimerScaledModel = TimeMode.UnScaled; 

        #endregion 

        private  float currentTime = 0f; // Current time ( 0 -- steptime) 
        private  int currentRepeat = 0 ; // current repeat times 
        private  float stepTime = 0f; // interval 
        private  int repeatTimes = 0 ; // repeat times 
        private  bool isLoop = false; // Whether to loop 
        private  bool isDone = false ; // Whether to complete 
        private  bool isStart = false ; // Whether to start 
        private  int updateIndex = 0 ; // The subscript obtained by update registration is used to remove update registration 
        private Action callback; // Callback 
        private  float timeAcceleration; // Increased time per frame 

        ///  <summary> 
        /// Is it complete
         ///  </summary> 
        public  bool IsDone 
        { 
            get =>isDone; 
        } 

        ///  <summary> 
        /// Current Progress
         ///  </summary> 
        public  float Progress 
        { 
            get => currentTime / stepTime; 
        } 

        ///  <summary> 
        /// Is it working
         ///  </ summary> summary> 
        public  bool IsWokring 
        { 
            get => !isDone && isStart; 
        } 

        ///  <summary> 
        ///  
        ///  </summary> 
        ///  <param name="stepTime"> Interval duration </param> 
        // / <param name="repeatTimes">times of repetition</param>
        /// <param name="callback">call-back</param>
        public Timer(float stepTime, int repeatTimes, Action callback)
        {
            this.currentTime = 0f;
            this.currentRepeat = 0;
            this.stepTime = stepTime;
            this.repeatTimes = repeatTimes;
            this.isLoop = false;
            this.isDone = false;
            this.timeAcceleration = GetPerTime();
            this.callback = callback;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="stepTime">interval</param>
        /// <param name="callback">call-back</param>
        public Timer(float stepTime, Action callback)
        {
            this.currentTime = 0f;
            this.currentRepeat = 0;
            this.stepTime = stepTime;
            this.repeatTimes = 1;
            this.isLoop = false;
            this.isDone = false;
            this.timeAcceleration = GetPerTime();
            this.callback = callback;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="stepTime">Interval</param>
        /// <param name="isLoop">Loop or not</param>
        /// <param name="callback">call-back</param>
        public Timer(float stepTime, bool isLoop, Action callback)
        {
            this.currentTime = 0f;
            this.currentRepeat = 0;
            this.stepTime = stepTime;
            this.isLoop = isLoop;
            if (!isLoop)
            {
                this.repeatTimes = 1;
            }
            this.timeAcceleration = GetPerTime();
            this.isDone = false;
            this.callback = callback;
        }

        /// <summary>
        /// Update every frame
         ///  </summary> 
        ///  <param name="addTime"> Added time per frame </param> 
        private  void Update( float addTime) 
        { 
            if (isDone)
                 return ;
             if (! isStart)
                 return ; 

            currentTime += addTime;
             if (currentTime >= stepTime) 
            { 
                callback ? .Invoke(); 
                currentTime = 0f;
                 if (!isLoop)
                {
                    ++currentRepeat;
                    if (currentRepeat >= repeatTimes)
                    {
                        isDone = true;
                        if (IsAutoRelease)
                        {
                            Stop();
                        }
                    }
                }
            }
        }

        /// <summary>
        /// TimerStart
        /// </summary>
        public void Start()
        {
            if(! UpdateRegister.IsInit) 
            { 
                Debug.LogWarning( " UpdateRegister is not init, so this action will not work, please init UpdateRegister first!!! " );
                 return ; 
            } 
            isStart = true ;
             this .updateIndex = UpdateRegister.Register(TimerUpdateMode , () => this .Update(timeAcceleration)); 
        } 

        ///  <summary> 
        /// Stop the timer (if you just want to pause the available Pause, the stop operation cannot be resumed)
         ///  </summary> 
        public  void Stop( ) 
        {
            isStart = false;
            isDone = true;
            UpdateRegister.Cancle(TimerUpdateMode, this.updateIndex);
        }

        /// <summary>
        /// Pause
        /// </summary>
        public void Pause()
        {
            isStart = false;
        }

        /// <summary>
        /// Continue
        /// </summary>
        public void Resume()
        {
            isStart = true; 
        } 

        ///  <summary> 
        /// Reset
         ///  </summary> 
        public  void Reset() 
        { 
            isStart = false ; 
            isDone = false ; 
            currentTime = 0f; 
            currentRepeat = 0 ; 
        } 

        ///  <summary> 
        / // No need to wait, complete directly
         ///  </summary> 
        public  void Complete() 
        { 
            if (isLoop)
                 return; 
            isDone = true ; 

            int tempRepeat = repeatTimes;
             while (tempRepeat > 0 ) 
            { 
                callback ? .Invoke();
                 -- tempRepeat; 
            } 
            Stop(); 

        } 

        ///  <summary> 
        /// Obtained by update mode and time mode Update time per frame
         ///  </summary> 
        ///  <returns></returns> 
        private  float GetPerTime() 
        { 
            float resultTime = 0f;
             if (TimerScaledModel == TimeMode.Scaled && TimerUpdateMode == UpdateMode.FixedUpdate)
            {
                resultTime = Time.fixedDeltaTime;
            }
            else if (TimerScaledModel == TimeMode.UnScaled && TimerUpdateMode == UpdateMode.FixedUpdate)
            {
                resultTime = Time.fixedUnscaledDeltaTime;
            }
            else if (TimerScaledModel == TimeMode.Scaled && TimerUpdateMode == UpdateMode.Update)
            {
                resultTime = Time.deltaTime;
            }
            else if (TimerScaledModel == TimeMode.UnScaled && TimerUpdateMode == UpdateMode.FixedUpdate)
            {
                resultTime = Time.unscaledDeltaTime;
            }
            return resultTime;
        }
    }
}

The third step is to simply write the test code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using JunFramework.Timer;

public class TimerExample : MonoBehaviour
{
    private Timer timer = null;
    // Start is called before the first frame update
    void Start()
    {
        Timer.IsAutoRelease = true;
        Timer.TimerScaledModel = JunFramework.TimeMode.UnScaled;
        Timer.TimerUpdateMode = JunFramework.UpdateMode.FixedUpdate;

        //Example1
        //int i = 0;
        //Timer timer = new Timer(2, 2, () => Debug.Log(i++));
        //timer.Start();

        //Example2
        //timer = new Timer(2, true, () => Debug.Log("Exeture"));
        //timer.Start();

        //Example3
        timer = new Timer(2, 3, () => Debug.Log("LookMe"));
        timer.Start();
        timer.Complete();

        timer.Reset();
        timer.Start();
    }

    // Update is called once per frame
    void Update()
    {
        //Example2
        //if (Input.GetKeyDown(KeyCode.Space))
        //{
        //    timer.Pause();
        //}
        //else if (Input.GetKeyDown(KeyCode.A))
        //{
        //    timer.Resume();
        //}
    }
}

error: rpmdb: BDB0113 Thread/process 14536/140712790841152 failed: BDB1507 Thread died in Berkeley DB library

yum remove docker
error: rpmdb: BDB0113 Thread/process 14536/140712790841152 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 – (-30973)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed
[root@localhost bin]# yum remove
error: rpmdb: BDB0113 Thread/process 14536/140712790841152 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 – (-30973)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed
[root@localhost bin]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 50G 11G 40G 21% /
devtmpfs 851M 0 851M 0% /dev
tmpfs 864M 0 864M 0% /dev/shm
tmpfs 864M 9.2M 854M 2% /run
tmpfs 864M 0 864M 0% /sys/fs/cgroup
/dev/sda2 1014M 139M 876M 14% /boot
/dev/sda1 200M 12M 189M 6% /boot/efi
/dev/mapper/centos-home 411G 33M 411G 1% /home
tmpfs 173M 0 173M 0% /run/user/0
[root@localhost bin]# mv /var/lib/rpm
rpm/ rpm-state/
[root@localhost bin]# mv /var/lib/rpm/
Basenames __db.001 __db.003 Dirnames Installtid Obsoletename Providename .rpm.lock Sigmd5
Conflictname __db.002 .dbenv.lock Group Name Packages Requirename Sha1header Triggername
[root@localhost bin]# mv /var/lib/rpm/__db.00
__db.001 __db.002 __db.003
[root@localhost bin]# mv /var/lib/rpm/__db.00
__db.001 __db.002 __db.003
[root@localhost bin]# mv /var/lib/rpm/__db.00* /tmp/ && yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up list of fastest mirrors
[root@localhost bin]# yum remove docker
Loaded plugins: fastestmirror
No Match for argument: docker

No Packages marked for removal
[root@localhost bin]#

[Solved] django mysql\base.py error: KeyError:

Tracking source code:

Problem file:Python36\lib\site-packages\django\db\backends\mysql\base.py

    def get_new_connection(self, conn_params):
        conn = Database. connect(** conn_params)
        conn.encoders[SafeText] = conn.encoders[six.text_type]
        conn.encoders[SafeBytes] = conn.encoders[bytes]
         return conn

 

solution

  1. Downgrade MySQLclient. Uninstall first, then install the specified version. pip3 uninstall mysqlclientpip3 install mysqlclient==1.3.
  2. My initial solution was to change the django code ( Python36\lib\site-packages\django\db\backends\mysql\base.py ), add an “if” as below:
    def get_new_connection(self, conn_params):
        conn = Database. connect(** conn_params)
        conn.encoders[SafeText] = conn.encoders[six.text_type] #First
         determine whether the bytes exist in the encoder, and if so, perform the operation 
        if bytes in conn.encoders:
            conn.encoders[SafeBytes] = conn.encoders[bytes]
         return conn
copy code

AlmaLinux 9.1: How to Install java11

001. system

[root@PC1 gatk- 4.1 . 9.0 ]# cat /etc/redhat- release 
AlmaLinux release 9.1 (Lime Lynx)

 

 

002. Test java command

[root@PC1 test]#java
bash: java: command not found...
Install package ' java-11-openjdk-headless ' to provide command ' java ' ? [N/y] ^ C               ## The installation is prompted by default
[root@PC1 test]# javac
bash: javac: command not found...
Install package ' java-11-openjdk-devel ' to provide command ' javac ' ? [N/y] ^C                 ## Same as above

 

003. Install directly according to the prompts

[root@PC1 test]#java
bash: java: command not found...
Install package ' java-11-openjdk-headless ' to provide command ' java ' ? [N/ y] y


 * Waiting in queue...
  * Loading list of packages....
The following packages have to be installed:
 java - 11 - openjdk - headless - 1 : 11.0.17.0.8-2.el9_0.x86_64 OpenJDK 11 Headless Runtime Environment
Proceed with changes ? [N/ y] y


 * Waiting in queue...
  * Waiting for authentication...

 

 

004. javac

[root@PC1 test]# yum list java- 11 * 
Last metadata expiration check: 0 : 24 : 45 ago on Thu 01 Dec 2022  05 : 41 : 24 PM CST.
Installed Packages
java - 11 - openjdk - headless.x86_64                                              1 : 11.0.17.0.8-2.el9_0 @appstream _ _ _
Available Packages
java - 11 - openjdk.x86_64                                                       1 : 11.0.17.0.8-2.el9_0 appstream _ _ _ _ _
java - 11 - openjdk - devel.x86_64                                                  1 : 11.0.17.0.8-2.el9_0 appstream java - 11 - openjdk - devel.x86_64              1 : 11.0.17.0.8-2.el9_0 appstream _
 _ _ _ _ _                                   
java - 11 - openjdk - javadoc.x86_64                                               1 : 11.0.17.0.8-2.el9_0 appstream _ _ _
java - 11 - openjdk - javadoc - zip.x86_64                                           1 : 11.0.17.0.8-2.el9_0 appstream _
java - 11 - openjdk - jmods.x86_64                                                 1 : 11.0.17.0.8-2.el9_0 appstream _ _ _
java - 11 - openjdk - src.x86_64                                                   1 : 11.0.17.0.8-2.el9_0 appstream _ _ _
java - 11 - openjdk - static - libs.x86_64                                           1 : 11.0.17.0.8-2.el9_0 appstream _ _ _
[root@PC1 test]#

 

005. Install javac

yum install java- 11 -openjdk-devel.x86_64

 

 

006. Test java and javac commands

java --version
javac --version

 

[Solved] Unreal Engine Error: Widget Blueprint could not be loaded because it derives from an invalid class

 Widget Blueprint could not be loaded because it derives from an invalid class 

The blueprint control could not be loaded because it is from an invalid class

To generate node widgets a class must be created

This is my problem when packaging a project with a custom plugin

The reason for the problem: When the compiler is opened, the plug-in is loaded by default after the compiler is loaded.

Solution:

In the .uplugin file put

" LoadingPhase " : " Default "

changed to

" LoadingPhase " : " PreDefault "

It means that the loading order of the plug-ins is mentioned before the compiler is loaded, so that this problem can be solved.

gatk: How to Merge vcf Files

001. Test data

[root@PC1 test]# ls                            ## test data
seg1_1.vcf seg1_2.vcf seg1_3.vcf
[root@PC1 test]# ll - h
total 1 .2G
 -rw-r--r--. 1 root root 392M Dec   1  18 : 14 seg1_1.vcf
 -rw-r--r--. 1 root root 410M Dec   1  18 : 15 seg1_2.vcf
 -rw -r--r--. 1 root root 386M Dec   1  18 : 14 seg1_3.vcf

 

 

002. Merge vcf files

g atk MergeVcfs -I seg1_1.vcf -I seg1_2.vcf -I seg1_3.vcf -O xxx.vcf ## merge command

 

The combined result is as follows:

[root@PC1 test]# ls
seg1_1.vcf seg1_2.vcf seg1_3.vcf xxx.vcf xxx.vcf.idx
[root@PC1 test]# ll - h 
total 2 .4G
 -rw-r--r--. 1 root root 392M Dec   1  18 : 14 seg1_1.vcf
 -rw-r--r--. 1 root root 410M Dec   1  18 : 15 seg1_2.vcf
 -rw-r--r--. 1 root root 386M Dec   1  18 : 14 seg1_3.vcf
 -rw-r--r--. 1 root root 1 .2G Dec   1  19 : 16 xxx.vcf
 -rw-r--r--. 1 root root 6.2K Dec   1  19 : 16 xxx.vcf.idx

 

 

003. Generate a list of vcf files that need to be merged

[root@PC1 test]# ls
seg1_1.vcf seg1_2.vcf seg1_3.vcf vcf.list
[root@PC1 test]# cat vcf.list ## Vcf list file to be merged
seg1_1.vcf
seg1_2.vcf
seg1_3.vcf
[root@PC1 test]# java -jar /home/software/picard/picard.jar MergeVcfs I=vcf.list O=xxx.vcf ## merge command

 

 

004. Merge result

[root@PC1 test]# ls
seg1_1.vcf seg1_2.vcf seg1_3.vcf vcf.list xxx.vcf xxx.vcf.idx
[root@PC1 test]# ll - h 
total 2 .4G
 -rw-r--r--. 1 root root 392M Dec   1  18 : 14 seg1_1.vcf
 -rw-r--r--. 1 root root 410M Dec   1  18 : 15 seg1_2.vcf
 -rw-r--r--. 1 root root 386M Dec   1  18 : 14 seg1_3.vcf
 -rw-r--r--. 1 root root    33 Dec   1  19 : 24 vcf .list
 -rw-r--r--. 1 root root 1.2G Dec   1  19 : 24 xxx.vcf
 -rw-r--r--. 1 root root 6 .2K Dec   1  19 : 24 xxx.vcf.idx