DingXiaoYu 3 лет назад
Родитель
Сommit
174aeaae15
6 измененных файлов с 661 добавлено и 7 удалено
  1. 8 7
      后端接口/Java-Controller.md
  2. 436 0
      后端接口/Java-Entity.md
  3. BIN
      图片/1.png
  4. BIN
      图片/2.png
  5. BIN
      图片/3.png
  6. 217 0
      服务器部署HDFS.md

+ 8 - 7
后端接口/Java-Controller.md

@@ -249,7 +249,7 @@ public class ModelVO {
 @RequestMapping("/userManage")
 public class LoginController {
     @Autowired private LoginService loginService;
-    
+
     /**
      *
      * @param username
@@ -257,31 +257,32 @@ public class LoginController {
      * @return checks
      */
     @CrossOrigin(origins = "http://localhost:8080/")
-    @GetMapping(value = "/login")
+    @PostMapping(value = "/login")
     public Response userLogin(@RequestParam(value="username", required = false) String username,
                               @RequestParam(value = "password", required = false) String password) {
         try {
             LoginPojo rsl = loginService.verifyUser(username, password);
             return new NormalRes(rsl);
         } catch (NullPointerException e) {
-            e.printStackTrace();
             return new ErrorRes(40001, "Username does not exist.");
         } catch (Exception e) {
-            e.printStackTrace();
             return new ErrorRes();
         }
     }
 
     /**
-     * 
+     *
      * @param user
      * @return
      */
     @PostMapping(value = "/register")
     public Response register(@RequestBody User user){     //注册,先判断该用户名是否已经存在
         boolean res=loginService.addUser(user);
-        if(res) return new NormalRes("add success");
-        else return new ErrorRes(40002,"Uses already exsists");
+        if(res){
+            return new NormalRes("add success");
+        } else{
+            return new ErrorRes(40002,"Uses already exsists");
+        }
     }
 }
 ```

+ 436 - 0
后端接口/Java-Entity.md

@@ -0,0 +1,436 @@
+# 1. inner
+
+## 1.1 LayerArgument
+
+```java
+public class LayerArgument {
+    @Id
+    private int id;
+    private boolean isDiscrete;  //是否为离散值
+    private String value; //参数的默认值
+    private String type;         //模型参数取值为Float|Int|...
+    private String valueDes;   //取值范围或者离散值则为取值量
+    private String description;  //对取值或者参数的说明
+}
+```
+
+这个类没有被任何类使用,这合理吗?
+
+## 1.2 ModelArgument
+
+```java
+public class ModelArgument {
+    @Id
+    private int id;
+    private String name;
+    private boolean isDiscrete;
+    private String defaultValue;
+    private String type;
+    private String valueDes;
+    private String description;
+}
+```
+
+# 2. Config
+
+```java
+public class Config {
+    @Id
+    private int id;
+
+    private int fileInfoId;      //文件id
+
+    private int userId;          //用户Id
+
+    private int modelTypeId;     //模型类id
+
+    private String confName;        //自定义模型名
+
+    private String fieldIds;   //选择训练的特征及特征描述
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    public int getId(){
+        return id;
+    }
+    public String getFieldIds(){
+        return fieldIds;
+    }
+}
+```
+
+fileInfoId,userId,modelTypeId都是外键。
+
+# 3. DLModel
+
+```java
+public class DLModel {
+    @Id
+    private int id;
+
+    private int modelTypeId; //模型的类别
+
+    private int picFileId;  //文件信息id
+
+    private String modelName;   //自定义的训练模型名
+
+    private boolean isTrained;  //是否进行了训练
+
+    private String modelPath;       //具体训练出的model
+
+    private String resOfModel; //模型训练的result
+
+    //模型的具体参数取值
+    private String arguments;  //模型的参数列表
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    public int getId(){
+        return id;
+    }
+}
+```
+
+modelTypeId,picFileId都是外键。
+
+# 4.FileInfo
+
+```java
+public class FileInfo {
+
+    @Id
+    private int id;
+
+    //.parquet file location
+    private String location;
+    //create time
+    private Date uploadTime;
+    //foreign key which connect to User table
+    private int userId;
+    //filename
+    private String filename;
+    //filename
+    private String folder;
+    //file structure
+    private String fileStrucInfo;
+
+    public FileInfo() {}
+
+    public FileInfo(String location, int userId, String filename) {
+        this.location = location;
+        this.userId = userId;
+        this.filename = filename;
+        this.uploadTime = new Date();
+    }
+    //for the scala use
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    public int getId() {
+        return id;
+    }
+    public String getLocation() {
+        return location;
+    }
+    public String getFilename() {return filename;}
+    public void setFileStrucInfo(String fileStrucInfo)
+    {
+        this.fileStrucInfo = fileStrucInfo;
+    }
+}
+```
+
+userId是外键。
+
+# 5. FuncInfo
+
+```java
+public class FuncInfo {
+    @Id
+    private int id;
+    private String funcDes;
+    private String funcName;
+    private int flagOfType;//0--String, 1--Double, 2--all
+    private int flagOfConOrDis;//0--con, 1--dis, 2--all
+
+    public FuncInfo(String funcDes, String funcName, int flagOfType, int flagOfConOrDis) {
+        this.funcName = funcName;
+        this.funcDes = funcDes;
+        this.flagOfType = flagOfType;
+        this.flagOfConOrDis = flagOfConOrDis;
+    }
+
+    public FuncInfo(int id, int flagOfType, int flagOfConOrDis) {
+        this.id = id;
+        this.flagOfType = flagOfType;
+        this.flagOfConOrDis = flagOfConOrDis;
+    }
+
+
+}
+```
+
+# 6. HeaderInfo
+
+```java
+public class HeaderInfo {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    private int id;
+    private int fileInfoId;  //文件id
+    private String fieldName;   //文件头的字段信息
+    private String aliasName;   //文件字段的别名
+    private String fieldDes;    //文件的描述信息
+    private double nullsRatio; //field的空值比例,为百分比 如10.00%
+    /**
+     * conOrDis 表示了这个field的类型
+     * 0表示离散值,1表示连续值,2表示时间
+     * @since 1.0 记录变量为离散值和连续值
+     */
+    private int conOrDis;
+    /**
+     * fieldType 表示了这个field的类型
+     * string, int, double ....
+     * @since 2.0 记录变量为离散值和连续值
+     */
+    private String fieldType;   //值的类型
+    /**
+     * @since 1.0 valueInfo使用String数组存储取值,如果是离散值则为取值,连续值则存储前两位min & max
+     */
+    //离散值的取值或者连续值的范围
+    private String valueInfo;
+
+    public HeaderInfo(int fileInfoId, String fieldName, String fieldType) {
+        this.fileInfoId = fileInfoId;
+        this.fieldName = fieldName;
+        this.aliasName = "";
+        this.fieldDes = "";
+        this.fieldType = fieldType;
+        this.valueInfo = null;
+        this.nullsRatio =0.0;
+    }
+    /*
+    * For the Fucking Stupid Scala Compiler
+    * */
+    public int getFileInfoId() { return this.fileInfoId; }
+    public String getFieldName() {
+        return this.fieldName;
+    }
+    public String getFieldType() { return this.fieldType; }
+
+    public double getNullsRatio() {
+        return nullsRatio;
+    }
+
+    public void setConOrDis(int conOrDis) {
+        this.conOrDis = conOrDis;
+    }
+    public void setValueInfo(String valueInfo) {
+        this.valueInfo = valueInfo;
+    }
+    public void setNullsRatio(double nullsRatio) {this.nullsRatio = nullsRatio;}
+}
+```
+
+fileInfoId是外键。
+
+# 7. Model
+
+```java
+public class Model {
+
+    @Id
+    private int id;
+
+    private int modelTypeId; //模型的类别
+
+    private int configId;    //文件配置id
+
+    private int fileInfoId;  //文件信息id
+
+    private String modelName;   //自定义的训练模型名
+
+    private boolean isTrained;  //是否进行了训练
+
+    private String modelPath;       //具体训练出的model
+
+    private String resOfModel; //模型训练的result
+    //模型的具体参数取值
+    private String arguments;  //模型的参数列表
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    public int getId(){
+        return id;
+    }
+
+    public void setConfigId(int configId) {
+        this.configId = configId;
+    }
+
+    public String getModelPath() {
+        return modelPath;
+    }
+
+    public void setModelPath(String modelPath) {
+        this.modelPath = modelPath;
+    }
+
+    public int getConfigId() {
+        return configId;
+    }
+}
+```
+
+modelTypeId,configId,fileInfoId是外键。
+
+# 8. ModelType
+
+```java
+public class ModelType {
+
+    @Id
+    private int id;
+
+    private String modelTypeName;
+
+    private String modelDetailName;
+
+    private String arguments;
+
+    private String modelDetailDes;
+
+    private String modelDes;
+
+    public ModelType(String modelTypeName, String modelDetailName, String arguments,
+                     String modelDetailDes, String modelDes) {
+        this.modelTypeName = modelTypeName;
+        this.modelDetailName = modelDetailName;
+        this.arguments = arguments;
+        this.modelDetailDes = modelDetailDes;
+        this.modelDes = modelDes;
+    }
+
+}
+```
+
+# 9. PicCategory
+
+```java
+public class PicCategory {
+
+    @Id
+    private int id;
+
+    private int picFileId;
+
+    private String categoryName;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    public int getId(){
+        return id;
+    }
+
+    public PicCategory(String categoryName, int picFileId) {
+        this.picFileId = picFileId;
+        this.categoryName = categoryName;
+
+    }
+
+}
+```
+
+picFileId是外键。
+
+# 10. PicFile
+
+```java
+public class PicFile {
+
+    @Id
+    private int id;
+    //foreign key which connect to User table
+    private int userId;
+
+    private String fileName;
+
+    private String loc;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    public int getId(){
+        return id;
+    }
+    public PicFile(int userId, String fileName, String loc){
+        this.userId = userId;
+        this.fileName = fileName;
+        this.loc = loc;
+    }
+}
+```
+
+userId是外键。
+
+# 11. PicInfo
+
+```java
+public class PicInfo {
+
+
+    @Id
+    private int id;
+
+    //.pic location
+    private String location;
+    //create time
+    private Date uploadTime;
+
+    //filename
+    private String picname;
+
+    private String tag;
+
+    private int categoryId;
+
+    public PicInfo() {}
+
+    public PicInfo(String location, String picname, String tag, int categoryId) {
+        this.location = location;
+        this.picname = picname;
+        this.uploadTime = new Date();
+        this.tag = tag;
+        this.categoryId = categoryId;
+    }
+    //for the scala use
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    public int getId() {
+        return id;
+    }
+    public String getLocation() {
+        return location;
+    }
+    public String getPicname() {return picname;}
+    public String getTag(){return tag;}
+
+}
+```
+
+# 12. User
+
+```java
+public class User {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Integer id;
+
+    private String username;
+    private String password;
+
+    public User(String username, String password) {
+        this.username = username;
+        this.password = password;
+    }
+}
+```
+




+ 217 - 0
服务器部署HDFS.md

@@ -0,0 +1,217 @@
+# 1. 下载JDK并且配置JAVA_HOME
+
+我拿到服务器的时候,java已经配好了,这边就不赘述了。
+
+# 2. 下载hadoop
+
+从清华大学镜像上下载:
+
+```
+wget https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-3.3.4/hadoop-3.3.4.tar.gz
+```
+
+解压:
+
+```
+ tar -zxvf hadoop-3.3.4.tar.gz
+```
+
+# 3. hadoop修改配置
+
+修改/etc/profile,注意具体路径:
+
+```
+export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
+
+export PATH=$JAVA_HOME/bin:$PATH
+export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
+
+export HADOOP_HOME=/root/hadoop-3.3.4
+export PATH=$PATH:$HADOOP_HOME/bin
+export PATH=$PATH:$HADOOP_HOME/sbin
+
+export HADOOP_MAPRED_HOME=$HADOOP_HOME
+export HADOOP_COMMON_HOME=$HADOOP_HOME
+export HADOOP_HDFS_HOME=$HADOOP_HOME
+export YARN_HOME=$HADOOP_HOME
+export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
+export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib/native"
+export PATH=${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HADOOP_HOME}/sbin:$PATH
+```
+
+然后使其生效:
+
+```
+source /etc/profile
+```
+
+hadoop-3.3.4目录下/etc/hadoop/的hadoop-env.sh文件,添加JAVA_HOME,注意一定要用绝对路径:
+
+```
+export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64export
+export HDFS_NAMENODE_USER=root
+export HDFS_DATANODE_USER=root
+export HDFS_SECONDARYNAMENODE_USER=root
+export YARN_RESOURCEMANAGER_USER=root
+export YARN_NODEMANAGER_USER=root
+```
+
+/etc/hadoop/的core-site.xml文件,注意文件路径,我设置了namenode为9001端口:
+
+```
+<configuration>
+    <property>
+        <name>fs.defaultFS</name>
+        <value>hdfs://master:9001</value>
+    </property>
+    <property>
+        <name>hadoop.tmp.dir</name>
+        <value>file:/root/hadoop-3.3.4/tmp</value>
+        <description>Abasefor other temporary directories.</description>
+	</property>
+    <property>
+        <name>fs.trash.interval</name>
+        <value>1440</value>
+    </property>
+</configuration>
+```
+
+/etc/hadoop/的hdfs-site.xml文件,注意文件路径:
+
+```
+<configuration>
+        <property>
+                <name>dfs.namenode.name.dir</name>
+                <value>file:/root/hadoop-3.3.4/hdfs/name</value>
+        </property>
+        <property>
+                <name>dfs.datanode.data.dir</name>
+                <value>file:/root/hadoop-3.3.4/hdfs/data</value>
+        </property>
+        <property>
+            <name>dfs.replication</name>
+            <value>1</value>
+        </property>
+        <property>
+            <name>dfs.permissions</name>
+            <value>false</value>
+        </property>
+</configuration>
+```
+
+/etc/hadoop/的yarn-site.xml:
+
+```
+<configuration>
+	<property>
+		<name>yarn.resourcemanager.hostname</name>
+		<value>master</value>
+	</property>
+	<property>
+		<name>yarn.nodemanager.aux-services</name>
+		<value>mapreduce_shuffle</value>
+	</property>
+</configuration>
+```
+
+/etc/hadoop的mapred-site.xml:
+
+```
+<configuration>
+   		<property>
+                <name>mapreduce.framework.name</name>
+                <value>yarn</value>
+        </property>
+        <property>
+                <name>mapreduce.jobhistory.address</name>
+                <value>master:10020</value>
+        </property>
+        <property>
+                <name>mapreduce.jobhistory.webapp.address</name>
+                <value>master:19888</value>
+        </property>
+</configuration>
+```
+
+# 4. 其他配置
+
+关闭防火墙:
+
+```
+ufw disable
+```
+
+添加主机映射:
+
+```
+hostnamectl set-hostname master
+```
+
+查看ip地址:
+
+```
+ip addr
+```
+
+![](.\图片\1.png)
+
+修改/etc/hosts,添加master:
+
+```
+10.0.16.6 master
+```
+
+然后尝试一下ping:
+
+```
+ping master
+```
+
+设置免密:
+
+```
+ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
+cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 
+chmod 0600 ~/.ssh/authorized_keys
+```
+
+# 5. 启动hadoop
+
+启动之前进行初始化,之后再启动不用再执行,如果有询问,输入y即可:
+
+```
+hadoop namenode -format
+```
+
+启动:
+
+```	
+start-dfs.sh
+start-yarn.sh
+```
+
+验证:
+
+```
+jps
+```
+
+![](./图片/2.png)
+
+验证能否在外网使用(一定要让服务器先暴露9001端口),使用公网ip:
+
+```
+telnet 124.222.139.8 9001
+```
+
+![](./图片/3.png)
+
+这表示可以访问
+
+关闭:
+
+```
+stop-dfs.sh
+stop-yarn.sh
+```
+